Thank you.. Can we do it from VBA?Please see if this one helps
T
Thank you.. Can we do it from VBA?
Why i am getting wrong result for Newark and Vancovour city, I think we also have to validate City with country ..J
Attached here is the file, just click on "Top2"Button
Attached is the file for ref.Why i am getting wrong result for Newark and Vancovour city, I think we also have to validate City with country ..
Sub Demo()
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Record")
.ClearAllFilters
If [F2].Value = 0 Or [F2].Value > .PivotItems.Count Then
Exit Sub
Else
.PivotFilters.Add2 _
Type:=xlTopCount, DataField:=ActiveSheet.PivotTables("PivotTable1"). _
PivotFields("Sum of Populations"), Value1:=[F2].Value
End If
End With
End Sub