Help with Pivot update event

Certified

Board Regular
Joined
Jan 24, 2012
Messages
189
Hi,

I uses pivotable to create financial statements from data.

There are three different group accounts (Ks, Ps and As).

I want each group account to have its own color.

My pivot table Range is from A to E. The last column (F) is for users to make comments.

When my user clicks on an account to disply more detail. I want the code below to run.

My issue is the code I have is not working. Any suggestions?



Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)

  Dim blueColorRange As Range
  Dim eRow As Integer
  Dim eColumn As Integer
  Dim i As Integer
  
  Sheet8.Activate
  
  If Target.Name = "PivotTable1" Then
  
  eRow = Cells(15, "a").End(xlDown).Row
  
  eColumn = Cells(15, "a").End(xlToRight).Column

  Set blueColorRange = Range(Cells(15, "a"), Cells(eRow, eColumn))
  
  
    For i = 15 To eRow
    
        If Left(Cells(i, "a"), 1) = "K" Then
        
            Range(Cells(i, "a"), Cells(i, "f")).Interior.Color = RGB(221, 235, 247)
        
        End If
        
        If Left(Cells(i, "a"), 1) = "A" Then
        
            Range(Cells(i, "a"), Cells(i, "f")).Interior.ColorIndex = 19
        
        End If
        
        If Left(Cells(i, "a"), 1) = "P" Then
        
            Range(Cells(i, "a"), Cells(i, "f")).Interior.Color = RGB(189, 215, 238)
    
         End If
    
    Next i

End If

End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

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