Hello Everyone,
The following VBA code that I have works to color the pivot title fields background color grey in my pivot table. I need help to modify it to start coloring from pivot title field "year" and not the entire row. I am providing a workbook example with this post just for a clear visual of what I am looking for.
Here is my Code:
Sub FormatHeaderRow()
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("Year").DataRange.EntireRow, _
.TableRange1)
.Font.Bold = True
.Font.ColorIndex = 1
.Interior.Color = RGB(222, 222, 222)
End With
End With
Bookmarks