+ Reply to Thread
Results 1 to 2 of 2

Macro to Modify Pivot Table for Color and Bold

  1. #1
    Cheryl B.
    Guest

    Macro to Modify Pivot Table for Color and Bold

    I've spent some time looking through the help menus and this queue but
    haven't found a solution ...

    I have a pivot table that will change as data is refreshed. I need to write
    a macro to find, change color and bold rows that contain the word 'Total'
    after the pivot table is created.

    Any ideas / suggestions are appreciated!
    Cheryl B.

  2. #2
    Bernie Deitrick
    Guest

    Re: Macro to Modify Pivot Table for Color and Bold

    Cheryl,

    Try the macro below. Change the line

    Set myFirstCell = Range("A7")

    to reflect a cell actually within your pivot table. If the sheet with the pivot table is not the
    active sheet at the time the macro is run, then you will need to change it to

    Set myFirstCell = Worksheets("Pivot Table Sheet").Range("A7")

    HTH,
    Bernie
    MS Excel MVP

    Sub ColorNBoldTotals()
    Dim c As Range
    Dim myFindString As String
    Dim firstAddress As String
    Dim myFirstCell As Range

    Set myFirstCell = Range("A7")
    myFindString = "total"

    With myFirstCell.CurrentRegion

    Set c = .Find(myFindString, LookIn:=xlValues, lookAt:=xlPart)

    If Not c Is Nothing Then
    With Intersect(c.EntireRow, .Cells)
    .Font.Bold = True
    With .Interior
    .ColorIndex = 6
    End With
    End With
    firstAddress = c.Address
    Else:
    MsgBox "Not Found"
    End
    End If

    Set c = .FindNext(c)
    If Not c Is Nothing And c.Address <> firstAddress Then
    Do
    With Intersect(c.EntireRow, .Cells)
    .Font.Bold = True
    With .Interior
    .ColorIndex = 6
    End With
    End With

    Set c = .FindNext(c)
    Loop While Not c Is Nothing And c.Address <> firstAddress
    End If
    End With

    End Sub


    "Cheryl B." <CherylB@discussions.microsoft.com> wrote in message
    news:A660689A-451F-4310-BF7C-E83C4CD0F38F@microsoft.com...
    > I've spent some time looking through the help menus and this queue but
    > haven't found a solution ...
    >
    > I have a pivot table that will change as data is refreshed. I need to write
    > a macro to find, change color and bold rows that contain the word 'Total'
    > after the pivot table is created.
    >
    > Any ideas / suggestions are appreciated!
    > Cheryl B.




+ 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