+ Reply to Thread
Results 1 to 1 of 1

Color Pivot Field Titles Macro Code Needs Minor Tweak

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-20-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2010
    Posts
    160

    Color Pivot Field Titles Macro Code Needs Minor Tweak

    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
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1