Pivot Table field macro

J

jackcwood

When I use private sub code below all works fine unless I add a field
not in the pivot then this code doesnt work how can i make sure that
if i choose a field
which is not in the pivot the vb will not input it ??

Cheers

If Target.Count > 1 Then Exit Sub
If IsEmpty(Target.Value) Then Exit Sub
If Target.Address = "$B$1" Then Worksheets("Pivot").PivotTables( _
"PivotTable1").PivotFields( _
"Month").CurrentPage = Target.Value
 
D

Debra Dalgleish

If you meant that the problem occurs if you choose an Item that's not in
the pivot field, there's sample code here that will check for each item
before changing the page field:

http://www.contextures.com/xlPivot09.html

Under the heading 'Check for Pivot Items Before Printing'

You could use something similar in your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top