Writing to the Page Field on a Pivot Table

davidmburrows

New Member
Joined
May 2, 2002
Messages
1
Could anyone please help?
Running Excel 97 SR-2 on windows NT4

I have a Pivot table with a number of pages
I have a Userform that creates a list of all the page values.
I then select from this list just the pages I want, and then print the selected pages.

The problem is:
I Have say 4 items in the selection list and I write each of these to the Pivot table page field in turn then print the page.
I will actually only get the first 3 pages.
When stepping through the VB code The Page variable has the correct value but the pivot table is typically one record out.
The very first record it tries to display is often a page from the table when originally saved and not necessarily in the list.

Here is the attached code

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
ListP = UserForm1.ListBox2.List

If ListBox2.ListCount = 0 Then
MsgBox ("No Pages Selected! ")
Else:
For Each Proj In ListP
If IsNull(Proj) = False Then
Sheets("Report").PivotTables("PivotTable2").PivotFields
("Project").CurrentPage = (Proj)
Sheets("Report").PrintOut Copies:=1

End If

Next Proj
End If

Application.ScreenUpdating = True

End Sub

Many Thanks Dave
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,213,487
Messages
6,113,943
Members
448,534
Latest member
benefuexx

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