Pivot Table (Filter) Macro

Jimmmy

New Member
Joined
Nov 29, 2010
Messages
25
Hey guys, I need your help (again). I've recorded a macro to create a pivot table. I have a filter to the pivot table referring to "Division", the value of which refers to the contents of a cell on another workbook.

I've declared the contents as the following:
Division = Workbooks("Macro.xls").Sheets("Macro").Range("P7").Value

The line referring to the pivot table filter is the following:
ActiveSheet.PivotTables("PivotTable1").PivotFields("Division").CurrentPage = Division

The macro runs on one sub program that calls on another before it ends. The sub program that is called changes the filter back to what "Division" is because before it is called, it is changed to something else (i.e. I believe it is "All"). Initially, this process did not work because I thought that I'd need to declare "Division", again, in the macro that is called, and not just in the main. When I did that, I get a totally different error that ruins the whole pivot table.

What I was wondering is if there's an easier way of doing all this that's error-free.

Thanks guys!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,224,602
Messages
6,179,839
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top