fuzzyjonclay
New Member
- Joined
- Jul 30, 2017
- Messages
- 9
Hi everyone
I've created a button (with a VBA script behind it) to update all worksheets in my spreadsheet.
The problems I'm having are as follows:
1. Even though I'm asking the script to take me back to the "DONUT VIEW" sheet it isn't. It does briefly but then seems to run through the entire script again and lands me on another worksheet within the spreadsheet.
2. The script doesn't work at all if I subsequently hide the worksheets. What would I need to do in order to resolve this?
Thank you for helping with this!
My script is shown below.
Best wishes
Jon
Sub data_update()
'
' data_update Macro
'
'
Sheets("DATA - Unapproved Income").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("DATA - School1").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
ActiveWindow.ScrollWorkbookTabs Sheets:=1
Sheets("DATA - School2").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("DATA - School3").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("DATA - School4").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
ActiveWindow.ScrollWorkbookTabs Sheets:=1
Sheets("PIVOTS").Select
Range("A6").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
Range("A25").Select
ActiveSheet.PivotTables("PivotTable5").PivotCache.Refresh
Range("D16").Select
ActiveSheet.PivotTables("PivotTable4").PivotCache.Refresh
Range("G2").Select
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
Range("G10").Select
ActiveSheet.PivotTables("PivotTable7").PivotCache.Refresh
Range("G20").Select
ActiveSheet.PivotTables("PivotTable8").PivotCache.Refresh
Range("G28").Select
ActiveSheet.PivotTables("PivotTable9").PivotCache.Refresh
Range("G36").Select
ActiveSheet.PivotTables("PivotTable10").PivotCache.Refresh
Range("G44").Select
ActiveSheet.PivotTables("PivotTable11").PivotCache.Refresh
Sheets("DONUT VIEW").Select
End Sub
I've created a button (with a VBA script behind it) to update all worksheets in my spreadsheet.
The problems I'm having are as follows:
1. Even though I'm asking the script to take me back to the "DONUT VIEW" sheet it isn't. It does briefly but then seems to run through the entire script again and lands me on another worksheet within the spreadsheet.
2. The script doesn't work at all if I subsequently hide the worksheets. What would I need to do in order to resolve this?
Thank you for helping with this!
My script is shown below.
Best wishes
Jon
Sub data_update()
'
' data_update Macro
'
'
Sheets("DATA - Unapproved Income").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("DATA - School1").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
ActiveWindow.ScrollWorkbookTabs Sheets:=1
Sheets("DATA - School2").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("DATA - School3").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
Sheets("DATA - School4").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
ActiveWindow.ScrollWorkbookTabs Sheets:=1
Sheets("PIVOTS").Select
Range("A6").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
Range("A25").Select
ActiveSheet.PivotTables("PivotTable5").PivotCache.Refresh
Range("D16").Select
ActiveSheet.PivotTables("PivotTable4").PivotCache.Refresh
Range("G2").Select
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
Range("G10").Select
ActiveSheet.PivotTables("PivotTable7").PivotCache.Refresh
Range("G20").Select
ActiveSheet.PivotTables("PivotTable8").PivotCache.Refresh
Range("G28").Select
ActiveSheet.PivotTables("PivotTable9").PivotCache.Refresh
Range("G36").Select
ActiveSheet.PivotTables("PivotTable10").PivotCache.Refresh
Range("G44").Select
ActiveSheet.PivotTables("PivotTable11").PivotCache.Refresh
Sheets("DONUT VIEW").Select
End Sub