I'm trying to create a macro that will create a new workbook and then copy all sheet(1)'s from all other open workbooks to it except for the workbook where I have all my macros stored. So far, I'm able to create the new workbook and save over it if needed (and it will be). But it's not copying the first worksheet of the open workbooks. Instead, it's copying the first worksheet of the new workbook and creating one new worksheet for each open workbook. Seems odd. Here's the code:
I'm trying to do this so that all the reports I download get put into one workbook, formatted, and then pulled into PowerBi. Any help is appreciated.
VBA Code:
Sub MergeWB()
Application.DisplayAlerts = False
Dim wb As Workbook
Workbooks.Add
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\User\Desktop\Client Dashboard\Client Dashboard.xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False, ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges
Application.DisplayAlerts = True
For Each wb In Workbooks
If wb.Name <> "Client Dashboard.xlsx" Or wb.Name <> "Macros.xlsm" Then
'Add today's date to cell A1 of first worksheet in workbook
Sheets(1).Copy After:=Workbooks("Client Dashboard.xlsx").Sheets(1)
End If
Next wb
End Sub
I'm trying to do this so that all the reports I download get put into one workbook, formatted, and then pulled into PowerBi. Any help is appreciated.
Last edited by a moderator: