ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Pivot table: how to programmatically format headers? (https://www.excelbanter.com/excel-discussion-misc-queries/113154-pivot-table-how-programmatically-format-headers.html)

Dave O

Pivot table: how to programmatically format headers?
 
I've been asked to apply some formatting to a pivot table: bold and
italics for subtotals, and underline headers. After studying Debra
Dalgleish's site I learned how to apply bold italic font to the
subtotals, comme ca:

Sub Pivot_Table_Format()
Dim PT As PivotTable
Dim PF As PivotField

On Error Resume Next
For Each PT In ActiveSheet.PivotTables
'Bold, italic subtotals
For Each PF In PT.PivotFields
PT.PivotSelect PF.Name & "[All;Total]", xlDataAndLabel, True
Selection.Font.Italic = True
Selection.Font.Bold = True
Next PF
Next PT

Range("a1").Select

End Sub

How do I find and apply formatting to the headers?

Thanks


Debra Dalgleish

Pivot table: how to programmatically format headers?
 
If you want to format the field buttons:

Sub Pivot_Table_Headings_Format()
Dim pt As PivotTable
Dim pf As PivotField

On Error Resume Next
For Each pt In ActiveSheet.PivotTables
For Each pf In pt.VisibleFields
pf.LabelRange.Font.Underline = True
Next pf
Next pt

End Sub


Dave O wrote:
I've been asked to apply some formatting to a pivot table: bold and
italics for subtotals, and underline headers. After studying Debra
Dalgleish's site I learned how to apply bold italic font to the
subtotals, comme ca:

Sub Pivot_Table_Format()
Dim PT As PivotTable
Dim PF As PivotField

On Error Resume Next
For Each PT In ActiveSheet.PivotTables
'Bold, italic subtotals
For Each PF In PT.PivotFields
PT.PivotSelect PF.Name & "[All;Total]", xlDataAndLabel, True
Selection.Font.Italic = True
Selection.Font.Bold = True
Next PF
Next PT

Range("a1").Select

End Sub

How do I find and apply formatting to the headers?

Thanks



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html


Dave O

Pivot table: how to programmatically format headers?
 
That did it- thanks very much!


Debra Dalgleish

Pivot table: how to programmatically format headers?
 
You're welcome. Thanks for letting me know that it worked.

Dave O wrote:
That did it- thanks very much!



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html



All times are GMT +1. The time now is 02:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com