Link to home
Create AccountLog in
Avatar of W.E.B
W.E.B

asked on

Excel Macro

Hello,
Can you please help,
I'm using below code to save sheets to new workbook.
the problem I have is, the sheet names are not always the same.

how can I change the code below to say,
Copy All sheets except "Main_Sheet"

Sub Export()
     
    Dim wb As Workbook, InitFileName As String, fileSaveName As String
    InitFileName = ThisWorkbook.Path & "\ - Recon_Output_ " & Format(Date, "yyyymmdd")
     Sheets(Array("SheetM1", "SheetMG1", "SheetHM1", "SheetJM1", "SheetK1", "SheetO1", "SheetL1", "SheetJY91")).Copy
    Set wb = ActiveWorkbook
      With wb
        .SaveAs "C:\Users\Wassim\Desktop\test)
        .Close False
    End With
    Range("A1").Select
    ActiveWorkbook.SAVE
End Sub

Any help is appreciated,
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of W.E.B
W.E.B

ASKER

Thank you.