Jagdev Singh
Active Member
Hi Experts
The below code is macro recorded and working fine, but consuming huge time to excute. Could you please help me to shrink the below code.
The below code is macro recorded and working fine, but consuming huge time to excute. Could you please help me to shrink the below code.
Code:
Sub PivotFormating()
Application.ScreenUpdating = False
ActiveSheet.PivotTables("PivotTable1").ManualUpdate = True
With ActiveSheet.PivotTables("PivotTable1")
With .PivotSelect("'Notes'[All]")
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With
With .PivotSelect("'Ins'")
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With
With .PivotSelect("'Date'")
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With
With .PivotSelect("'DueDate'")
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With
Range(Selection, Selection.End(xlToRight)).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With
ActiveWindow.Zoom = 90
Columns("A:A").ColumnWidth = 30
Columns("B:B").ColumnWidth = 14.43
Columns("C:C").ColumnWidth = 16.43
Columns("D:D").ColumnWidth = 23.29
Columns("E:E").ColumnWidth = 20.86
Columns("F:F").ColumnWidth = 19.43
Columns("G:G").ColumnWidth = 16.43
Columns("H:H").ColumnWidth = 30
Columns("H:H").Select
Selection.Style = "Comma"
Columns("I:I").Select
Selection.Style = "Comma"
ActiveSheet.PivotTables("PivotTable1").ManualUpdate = False
Application.ScreenUpdating = True
End Sub