Visible item in PageField

phoeberunner

New Member
Joined
May 12, 2011
Messages
16
Hi All,

I have "Country" in a pivot PageField.
The "Country" field has 4 pivotItems: China, India, Spain, Taiwan, where China is unchecked.

I would like to know visible (checked) items for "Country" field.

Here is my code,

For i = 1 To pvt.PageFields.Count
With mySheet
.Range(.Cells(1, 1), .Cells(nRowEnd, nColEnd)).Select
Selection.AutoFilter

If pvt.PageFields(1).AllItemsVisible <> True Then
For k = 1 To pvt.PageFields(i).PivotItems.Count
Debug.Print pvt.PageFields(i).PivotItems(k).Visible
Next k
End If
End With
Next i

The result returned is
FALSE
FALSE
FALSE
FALSE

The correct result is supposed to be
FALSE
TRUE
TRUE
TRUE
as China is unchecked and the rest is checked.

Does anyone know to solve my problem?

Thanks!
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Can't really tell...

but this snippet follows my PT Page Filters every time.
Code:
For i = 1 To pvt.PageFields.Count
    If pvt.PageFields(1).AllItemsVisible <> True Then
        Debug.Print vbLf; "=========================="
        Debug.Print "Country"; Tab(20); "Checked"
        Debug.Print "=========================="
        For k = 1 To pvt.PageFields(i).PivotItems.Count
            Debug.Print pvt.PageFields(i).PivotItems(k).Caption _
            ; Tab(20); pvt.PageFields(i).PivotItems(k).Visible
        Next k
    End If
Next i

==========================
Country Checked
==========================
China False
India True
Spain True
Taiwan True

might ensure pvt is set to the expected Pivot Table.
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,480
Members
452,915
Latest member
hannnahheileen

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