I have multiple pivot tables on one same worksheet (from left to right : PvtTable 1, Pvttable 2, Pvttable3). I have introduced a iterator (i) to call them one after the other (msgbox their name). However, when i run the macro, the names are in an illogical order : they don't display pvttable1 then 2 then 3 nor backwards (3,2,1). It displays pvttable2, pvttable1, pvttable3. Is there a tool that wold help me initiate and tell VBA which one to call first ? What is this order based on ? Simple piece of code I use that returns a weird order :
For i = 1 to 3
MsgBox ActiveSheet.PivotTables(i).Name
Next i
*my pivot tables have changing string names btw, the names mentioned are just examples to help make understand they don't appear in order
Thanks everyone, hope it was clear!
ActiveSheet.PivotTables("pvttable" & i), or you can read all the names in a dictionary first and then sort the dictionary.