Using VBA to select objects in a PIVOT TABLE

MBinMTL

New Member
Joined
Nov 6, 2006
Messages
29
Hello,

Thanks to Matt I now know how to de-select all the items in a specific pivot field using VBA. The code he gave me is pasted below.

The challenge now is to select specific items. When I try the following command I get an error.

Here is the code:

With ActiveSheet.PivotTables("Query_Data").PivotFields("Begin_time")
.PivotItems("11-Jun").Visible = True
End With

Here is the error:

Unable to set the Visible property of the PivotItem class

Here is the code used to de-select all PivotItems:

Dim I As Integer
Dim Item As Object
I = 0
For Each Item In ActiveSheet.PivotTables("Query_Data").PivotFields("Begin_Time").PivotItems
If I >= 1 Then
With ActiveSheet.PivotTables("Query_Data").PivotFields("Begin_Time")
Item.Visible = False
End With
End If
I = I + 1
Next
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hey MB,

Ever get a response to this or figure it out? I am getting the same issues myself.

Ryan
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

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