Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
I'm trying to write a macro to highlight the total rows in my pivot tables. I have Office 03. Does anyone know how I can determine what colums / rows the pivot table occupies to so that I can apply the correct formatting? I have some code that doesn't work too well (posted at the bottom) The logic of the program I want to write is: Get the range that the pivot table occupies (e.g. A3:F100) (referred to below as Pivot Range) For each cell in the Pivot Range (assuming that the loop will go a3, b3, c3, d3....) if the cell contains the word Total then Format the row from the current cell to the last column of the pivot table range a certain color go to the next row The only other thing worth noting is that I only want to highlight from the column with the total to the end of the pivot, so if c3 contains a total then in the example above, c3 - f3 would be highlighted. My code so far: Sub Help() Dim pt As PivotTable Set pt = ActiveCell.PivotTable pt.TableRange2.Select 'this selects the range that the pivot occupies For Each Cell In Selection Set x = Cell.Find("Total") If x = "" Then x = "" Else With Cell.Interior .ColorIndex = 26 .Pattern = xlSolid .PatternColorIndex = xlAutomatic End With End If Next Exit Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pivot Table % of Totals | Excel Discussion (Misc queries) | |||
Pivot Table Totals | Excel Discussion (Misc queries) | |||
Pivot Table - Sub totals | Excel Discussion (Misc queries) | |||
Pivot table totals | Excel Discussion (Misc queries) | |||
Pivot Table Totals | New Users to Excel |