I'd like to setup a macro so that Excel will refresh the query in each sheet in an open workbook and then copy everything to a new blank workbook. With that, I'd like it to be able to do this for all open workbooks.
Here's the code I currently have, but all it does is copy the first workbook several times for the amount of other workbooks that are open.
Here's the code I currently have, but all it does is copy the first workbook several times for the amount of other workbooks that are open.
Code:
Sub ASInvRefresh()
Dim qt As QueryTable
Dim ws As Worksheet
Dim wb As Workbook
For Each wb In Workbooks
For Each ws In wb.Worksheets
If StrComp(wb.name, "personal.xls", vbTextCompare) <> 0 Then 'skip the personal wb
For Each qt In ws.QueryTables
qt.Refresh False
Next qt
ws.Cells.EntireColumn.AutoFit
End If
Next ws
Worksheets.Copy
ActiveWorkbook.Colors = wb.Colors
Next wb
End Sub