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?
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