none
sorting multi pivot.table with use VBA RRS feed

  • Question

  • Dear all...

    i am trying to sorting pivot-table value with this code:

      ActiveSheet.PivotTables("PivotTable1").PivotFields("Model").AutoSort 

    it's OK for data by Model .... but I wan't to use the same code for an example  Brand data or other.. 

    my question .... how can I change "Model" word in my code and replaced with the word in column 10 row 2 ( G2 ) in the same sheet.

      ActiveSheet.PivotTables("PivotTable1").PivotFields("{the word in G2 cell }").AutoSort 

    Wednesday, June 12, 2019 12:30 PM

Answers

  • Basically exactly like what you have:

    ActiveSheet.PivotTables("PivotTable1").PivotFields(ActiveSheet.Range("G2").Value).AutoSort 


    • Edited by Stefan Hoffmann Wednesday, June 12, 2019 1:05 PM
    • Marked as answer by G.Dalati Wednesday, June 12, 2019 4:44 PM
    Wednesday, June 12, 2019 1:05 PM

All replies