Hiding PivotItems

G

Gina Liddle

I want to match the UserName to a PivotItem in the PivotField "PL", so to
display that item and hide all others. But when I run the below code I get
Run-time error 1004. However if I change the Visible = False is runs without
error.

How do I hide all items except the one that matches the UserName?

Ta,

G



Set APT = ActiveWorkbook.Worksheets("Job Monitoring").PivotTables _
("Job Monitoring Report").PivotFields("PL")

ResNum = APT.PivotItems.Count

ReDim ResID(ResNum)

For Res = 1 To ResNum
ResID(Res) = APT.PivotItems(Res)

fOSUserName
If fOSUserName = ResID(Res) Then
APT.PivotItems(ResID(Res)).Visible = True
End If

Next Res
 

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