In advance, thanks so much for your time and attention.
I am using a pivot table to query a large spreadsheet for select data. The pivot table is always four columns wide but can vary widely in length. I have recorded a macro to select the appropriate area to print, format the selected area however, I am not able to get the macro to "re-define" the print area after the pivot table is refreshed and the appropriate area is selected. The following code does all the above stated tasks nicely but the ActiveSheet.PageSetup.PrintArea = "$B$10:$E$19" line fails me. Clearly I need help getting around the absolute range reference.
Thanks again.
Sub RefreshPivotClassType()
'
' RefreshPivotClassType Macro
'
'
ActiveSheet.PivotTables("PivotClassType").PivotCache.Refresh
Columns("B:B").Select
Selection.ColumnWidth = 15
Columns("C:C").Select
Selection.ColumnWidth = 15
Columns("D:D").Select
Selection.ColumnWidth = 45
Columns("E:E").Select
Selection.ColumnWidth = 9
Range("E9").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToLeft)).Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveSheet.PageSetup.PrintArea = "$B$10:$E$19"
Range("B9").Select
End Sub
Bookmarks