• Do you need to provide monthly Excel stats to a bunch of external customers?
• Do you need to refresh the data in 50+ workbooks every month?
• Are you tired of mind-numbingly opening a workbook after workbook only to press “Refresh All”?
There’s a way to avoid all these!
1) Put the file paths of all files that need refreshing as in picture below
2) Use this VBA snippet in order to trigger the automatic refresh
Sub RefreshMonthly() | |
Dim Cell As Range | |
Dim Source As String | |
Dim Target As String | |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
'written by Angelina Teneva, September 2016 | |
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Application.ScreenUpdating = False | |
Application.DisplayAlerts = False | |
For Each Cell In ThisWorkbook.Worksheets("monthly").Range("A2:A" & Worksheets("monthly").UsedRange.Rows.Count) | |
Source = Cell.Value | |
Target = Cell.Offset(0, 2).Value | |
Workbooks.Open FileName:=Source, ReadOnly:=False, UpdateLinks:=False | |
With ActiveWorkbook | |
.RefreshAll | |
.saveas Target | |
.Close | |
End With | |
Next Cell | |
MsgBox ("Refresh Completed") | |
Application.ScreenUpdating = True | |
Application.DisplayAlerts = True | |
End Sub |
NB! Be aware – the success of the approach depends on several factors:
• Your spreadsheet is connected to a database or to a CSV connection which does not require manual file selection upon refresh
• Pivot tables in the spreadsheet have been designed and positioned in such a way that it is unlikely their refresh will cause them to get in each other’s way (best try to stick to 1 pivot table per sheet)
• The workbooks to be refreshed are password-free and so are the refresh-impacted worksheets (actually, you can get around this, but the VBA code above will require a few extra lines)
Ready to try?
Happy VBA coding!