My code that formats certain rows on my pivot table works when I step through the code, step by step. However, when I assigned the macro to a button, with other macros, it didn't complete the formatting in the finished product. As a result, when I copied the pivot table data across to a new sheet, the correct formatting wasn't present.
Basically I am trying to format certain rows in the pivot table, and then copy the values and format of the pivot table to a new sheet and format the rest there (as formatting the pivot table is slowing down my macro considerably).
Here is the start of my code:
Sub formatpt()
'formatpt Macro
Dim ws As Worksheet
Set ws = Worksheets("Pivot")
Dim pt As PivotTable
Set pt = Worksheets("Pivot").PivotTables("Dashboard")
pt.ShowTableStyleRowHeaders = False
pt.ShowDrillIndicators = False
pt.PivotSelect "Region[All]", xlLabelOnly + _
xlFirstRow, True
Selection.Interior.Color = RGB(128, 128, 128)
Selection.RowHeight = 40
Selection.Font.Bold = True
Selection.Font.Color = vbWhite
pt.PivotSelect "Desk[All]", xlLabelOnly + _
xlFirstRow, True
Selection.Interior.Color = RGB(166, 166, 166)
Selection.RowHeight = 35
Selection.Font.Bold = True
pt.PivotSelect "Style[All]", xlLabelOnly + _
xlFirstRow, True
Selection.Interior.Color = RGB(217, 217, 217)
Selection.RowHeight = 20
Selection.Font.Bold = True
Set ws2 = Worksheets("Final")
ws.Range("A1").CurrentRegion.Copy
ws2.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone _
, SkipBlanks:=False, Transpose:=False
ws.Range("A1").CurrentRegion.Copy
ws2.Range("A1").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
The row heights don't copy across either, but this is less important. But if you do know how to copy across row height as well as the formatting and values, then please let me know.
Any help is greatly appreciated.
Thanks