M
Moily
Hi there,
I've got one sheet in a large workbook (Excel 2003) that is made up of Pivot
Charts. I would like for those charts to be updated everytime the sheet is
opened within the book. I think a macro would probably be best (but please
tell me otherwise if you know another method!) and am using the below code
but there are a few difficulties:
It's meant to update all the pivot tables in the sheet as soon as it's
opened and then readjust the column widths. The problem is that it isn't
isolated just to the one worksheet (called "CrossTabQs") and instead runs
this macro for ALL the sheets in the workbook. Can anyone help? Thank you in
advance!!!! - Ann
Code as follows:
Sub Auto_Open()
Application.OnSheetActivate = "UpdateIt"
Application.OnSheetActivate = "AdjustColumns"
End Sub
Sub UpdateIt()
Dim iP As Integer
Application.DisplayAlerts = False
For iP = 1 To ActiveSheet.PivotTables.Count
ActiveSheet.PivotTables(iP).RefreshTable
Next
Application.DisplayAlerts = True
End Sub
Sub AdjustColumns()
Cells.Select
Range("A6").Activate
Selection.ColumnWidth = 26.14
Columns("B:H").Select
Range("B6").Activate
Selection.ColumnWidth = 16.43
Range("E50").Select
End Sub
I've got one sheet in a large workbook (Excel 2003) that is made up of Pivot
Charts. I would like for those charts to be updated everytime the sheet is
opened within the book. I think a macro would probably be best (but please
tell me otherwise if you know another method!) and am using the below code
but there are a few difficulties:
It's meant to update all the pivot tables in the sheet as soon as it's
opened and then readjust the column widths. The problem is that it isn't
isolated just to the one worksheet (called "CrossTabQs") and instead runs
this macro for ALL the sheets in the workbook. Can anyone help? Thank you in
advance!!!! - Ann
Code as follows:
Sub Auto_Open()
Application.OnSheetActivate = "UpdateIt"
Application.OnSheetActivate = "AdjustColumns"
End Sub
Sub UpdateIt()
Dim iP As Integer
Application.DisplayAlerts = False
For iP = 1 To ActiveSheet.PivotTables.Count
ActiveSheet.PivotTables(iP).RefreshTable
Next
Application.DisplayAlerts = True
End Sub
Sub AdjustColumns()
Cells.Select
Range("A6").Activate
Selection.ColumnWidth = 26.14
Columns("B:H").Select
Range("B6").Activate
Selection.ColumnWidth = 16.43
Range("E50").Select
End Sub