Reputation: 69
I am working with two workbooks. I am inserting data in one and the other is taking part of this data via Excel query, thus I have to open the second one every time I want to refresh the information, as I am sharing it with other users.
In few words, I would like to remotely refresh the second workbook when I am updating the main one so I do not have to continuously open, refresh and close.
Let's assume that both workbooks are in the same folder in Dropbox, for example.
Thanks a lot!
Upvotes: 0
Views: 5767
Reputation: 69
I have found a way, however it does not work in Mac OS as queries are not supported (I did not know about this).
For those who it might help, below the code:
Sub RefreshWB()
Application.ScreenUpdating = False
ActiveWorkbook.Save
Dim wb As Excel.Workbook
Set wb = Application.Workbooks.Open(ThisWorkbook.Path & Application.PathSeparator & "workbook.xlsx")
wb.Sheets("Sheet 1").Range("A1").ListObject.QueryTable.Refresh BackgroundQuery:=False
wb.Save
wb.Close
Application.ScreenUpdating = True
End Sub
Upvotes: 1