bulldaddy1
New Member
- Joined
- Aug 25, 2009
- Messages
- 39
Good afternoon...
I recorded a Macro for a pivot table that turns on the Top 10 Value Filter and it works perfectly...however, if I was to click on the command button after it has already filtered the Top 10, I get a Run-time error 1004.
Is there any code that could be added to prevent this from happening?
Thank you for your time and expertise!
Sub Top10Units()
'
' Top10Units Macro
'
'
ActiveSheet.PivotTables("PivotTableUnit").PivotFields("Brand").PivotFilters. _
Add2 Type:=xlTopCount, DataField:=ActiveSheet.PivotTables("PivotTableUnit") _
.PivotFields("CY Vol"), Value1:=10
Range("J6").Select
End Sub
I recorded a Macro for a pivot table that turns on the Top 10 Value Filter and it works perfectly...however, if I was to click on the command button after it has already filtered the Top 10, I get a Run-time error 1004.
Is there any code that could be added to prevent this from happening?
Thank you for your time and expertise!
Sub Top10Units()
'
' Top10Units Macro
'
'
ActiveSheet.PivotTables("PivotTableUnit").PivotFields("Brand").PivotFilters. _
Add2 Type:=xlTopCount, DataField:=ActiveSheet.PivotTables("PivotTableUnit") _
.PivotFields("CY Vol"), Value1:=10
Range("J6").Select
End Sub