Pivot Table in Macro

sjonelunas

New Member
Joined
Aug 11, 2008
Messages
28
I'm having some trouble with this one. I have a macro that created a pivot table then runs through pivot field options to copy and paste selected data into other sheets. I'm trying to figure out how to tell the macro that if one of the choices isn't yet a choice in the source data to move on to the next one. I tried:

Code:
On Error Resume Next
    ActiveSheet.PivotTables("PivotTable7").PivotFields("MRP Code").CurrentPage = _
        "HEV"
    On Error GoTo 0

Instead of moving on to the next line of code it changes the pivot field to read HEV and moves on as if it were real when HEV wasn't really a choice in the drop down box.

Any suggestions? Does this make any sense?

Thanks!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
part of your problem appears to be, is that on error resume next, its doing just that, finding an error and carrying on
 
Upvote 0
I thought it would flag it as an error because HEV is not yet an option in the drop down box for the report view, but it isn't. It's changing the option in the report field box as if it were typing over it and changing the name of the currently selected page field.

I'm trying to figure out how to keep it from changing the name of the page field and to just error if it's not an option.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
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