Help with PivotSelect command in Macro

storm925

Board Regular
Joined
Jan 20, 2010
Messages
226
Hello all, I'm looking for a little help with the PivotSelect command in a macro I am trying to write. I am still new at writing macros, so thank you for your help on this. My goal is that if the Pivot Field "Nbr" contains any of the numbers in the String "Y", it will highlight it yellow. Here is my macro so far that is not working, however I know that I am close.

Code:
Sub Highlight_Row()

Dim PI As PivotItem
Dim Y As String
    
Y = 4175, 1780, 5535, 1123
    
For Each PI In Worksheets("Service").PivotTables("PivotTable1").PivotFields("Nbr").PivotItems   
    If PI = Y Then
    ActiveSheet.PivotTables("PivotTable3").PivotSelect " 'Y' ", xlDataAndLabel, True
       With Selection.Interior
            .ColorIndex = 36
            .Pattern = xlSolid
        End With
    End If
Next PI

End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,206,831
Messages
6,075,118
Members
446,123
Latest member
junkyardforme

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