Sorry, this is going to get wordy.
I am trying to figure out if there is some VBA code to sort Pivot tables based on the selection of a drop down. I basically want to sort the pivot table largest to smallest on the column that corresponds to that month. I.e. a user selects May from the drop down I would like to sort the PT on “Sum of YTD Billings May (USD)” [it will always be “Sum of YTD Billings “&left(month,3)&” (USD)”.
I would like it to simulate right clicking on $AQ$6 and selecting [sort>sort largest to smallest].
The absolute reference will not move so Jan-Dec will always be AM6-AX6 if that makes this easier.
I can conceptually figure out how to get myself to the cell:
I can just hlookup $AM$3-$AX$6 for “sum of YTD billings “&left(dropdown,3)”&” (USD) then offset 3,0.
Or start at the anchor of $AM$3 and offset 3,(a lookup value for the month Jan=1, Feb=2, etc…).
The attached workbook is the general idea. It’s all dummy data but the column names and sheet names are the same. I have working formulas everywhere else, I was just hoping to get able to get the PT’s to sort for me for some dynamic changes made easy
Any help would be amazing
VBA to sort PT by columns.xlsx
Bookmarks