Hi Everyone,
I am trying to fix my VBA code, but I can't seem to find out what is wrong with it. The second part of code should change the cell background color all cells associated with the value "N8F", but for some reason the color stops on cell A72 when it should stop at A127.
Here is the first part of my code which works fine:
Here is the second part of code which does not work like it suppose to:
I am trying to fix my VBA code, but I can't seem to find out what is wrong with it. The second part of code should change the cell background color all cells associated with the value "N8F", but for some reason the color stops on cell A72 when it should stop at A127.
Here is the first part of my code which works fine:
Code:
Sub FormatHeaderRowDos()
Dim c As Range
Dim PT As PivotTable
Dim PivotRange As Range
Set PT = ActiveSheet.PivotTables(1)
Set PivotRange = PT.DataBodyRange
With ActiveSheet.PivotTables(1)
With .TableRange1
.Interior.ColorIndex = 0
.Font.Bold = False
End With
With Intersect(.PivotFields("FiscalYear").DataRange.EntireRow, _
.TableRange1)
.Font.Bold = True
.Font.ColorIndex = 35
.Interior.ColorIndex = 56
End With
End With
Here is the second part of code which does not work like it suppose to:
Code:
Dim cell As Range
Dim ColourIndex As Long
Dim LastRow As Long
Set PT = ActiveSheet.PivotTables(1)
Set PivotRange = PT.DataBodyRange
LastRow = Range("B" & Rows.Count).End(xlUp).Row
For Each cell In Range("A10:A" & LastRow)
Select Case cell.Value
Case "N8F"
ColourIndex = RGB(235, 241, 222)
Case Is = "N45"
ColourIndex = RGB(235, 241, 222)
End Select
cell.Interior.Color = ColourIndex
Next