Hello Community,
Looking for a little VBA love. Current macro simply done by recording. So I couldn't screw up the language code.
I have 2 sheets: 1 for Brands and Brands Top Gain Loss. I would like to get rid of one sheet and allow a macro for Sort by "Dollar Sales" and "Dollar Sales Chg YA". And then filter to the Top 20 or Bottom 20.
Sub Top20Rank()
' Top20Rank Macro
Range("D8").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Brands").AutoSort _
xlDescending, "Dollar Sales Chg YA", ActiveSheet.PivotTables("PivotTable1"). _
PivotColumnAxis.PivotLines(3), 1
Range("A8").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Brand Value").PivotFilters. _
Add2 Type:=xlTopCount, DataField:=ActiveSheet.PivotTables("PivotTable1"). _
PivotFields("Dollar Sales Chg YA"), Value1:=20
End Sub
I get the Error 1004. Any chance you can help with the error?
Thank you as always in advance.
Looking for a little VBA love. Current macro simply done by recording. So I couldn't screw up the language code.
I have 2 sheets: 1 for Brands and Brands Top Gain Loss. I would like to get rid of one sheet and allow a macro for Sort by "Dollar Sales" and "Dollar Sales Chg YA". And then filter to the Top 20 or Bottom 20.
Sub Top20Rank()
' Top20Rank Macro
Range("D8").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Brands").AutoSort _
xlDescending, "Dollar Sales Chg YA", ActiveSheet.PivotTables("PivotTable1"). _
PivotColumnAxis.PivotLines(3), 1
Range("A8").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Brand Value").PivotFilters. _
Add2 Type:=xlTopCount, DataField:=ActiveSheet.PivotTables("PivotTable1"). _
PivotFields("Dollar Sales Chg YA"), Value1:=20
End Sub
I get the Error 1004. Any chance you can help with the error?
Thank you as always in advance.