Select Power Pivot PT Item

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,598
Office Version
  1. 365
Platform
  1. Windows
I am looping through row labels in a PT using the following (which doesn't feel efficient but it's the only way I can check each item value)
Code:
Set ptField = ptPivotTableList.PivotFields("[AD Expected].[Proper Name].[Proper Name]")
      
      For Each ptItem In ptField.PivotItems
         Set rngPerson = Range("FA_IndividualsStartBDM").Offset(1, 0)
         
         Do Until rngPerson = ""
         
            If InStr(ptItem.Name, rngPerson.Value) > 0 Then
               strPerson = rngPerson
               
               Exit Do
               Else
               strPerson = ""
            End If
            Set rngPerson = rngPerson.Offset(1, 0)
         Loop
            
         If strPerson = "" Then
            Else
            If rngPerson.Offset(0, 2) = strSector And rngPerson.Offset(0, 3) = "N" Then
               ptItem.Visible = True
               Else
               ptItem.Visible = False
            End If
         End If
      Next
My problem is with the ptItem.Visible = part as I am getting a 1004 error.

Again, I've not got a clue why this isn't working but I'm assuming it's because it using the Power Pivot to establish the PT.


TIA
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I thought the following would work but it's causing a run time error
Code:
Dim strArray As String

strArray = ""
      Do Until rngPerson = ""
            If strArray = "" Then
               strArray = Chr(34) & "[AD Expected].[Proper Name].&[" & rngPerson & "]" & Chr(34)
               Else
               strArray = strArray & ", " & Chr(34) & "[AD Expected].[Proper Name].&[" & rngPerson & "]" & Chr(34)
            End If

         Set rngPerson = rngPerson.Offset(1, 0)
      Loop"

ptPivotTableList.PivotFields("[AD Expected].[Proper Name].[Proper Name]").VisibleItemsList = Array(strArray)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,563
Messages
6,114,332
Members
448,566
Latest member
Nickdozaj

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