Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Cheryl B.
 
Posts: n/a
Default 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   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

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." wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
updating pivot table to include additional rows Ellen Excel Discussion (Misc queries) 8 July 15th 08 01:33 PM
Pivot table, dynamic data formula Excel GuRu Excel Discussion (Misc queries) 3 May 3rd 05 10:45 PM
Macro to change a Pivot Table David M Excel Discussion (Misc queries) 0 March 22nd 05 05:27 PM
Pivot Table Problems Rachel Gonsior Excel Discussion (Misc queries) 3 March 21st 05 07:24 PM
Macro for Pivot Tables Thomas Excel Discussion (Misc queries) 1 March 15th 05 01:03 AM


All times are GMT +1. The time now is 04:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"