How to copy only a single worksheet to another workbook using vba

后端 未结 4 798
天涯浪人
天涯浪人 2020-12-01 13:11

I have 1 WorkBook(\"SOURCE\") that contains around 20 Sheets.
I want to copy only 1 particular sheet to another Workbook(\"TARGET\") using Exce

4条回答
  •  情深已故
    2020-12-01 13:28

    I have 1 WorkBook("SOURCE") that contains around 20 Sheets. I want to copy only 1 particular sheet to another Workbook("TARGET") using Excel VBA. Please note that the "TARGET" Workbook doen't exist yet. It should be created at runtime.

    Another Way

    Sub Sample()
        '~~> Change Sheet1 to the relevant sheet
        '~~> This will create a new workbook with the relevant sheet
        ThisWorkbook.Sheets("Sheet1").Copy
    
        '~~> Save the new workbook
        ActiveWorkbook.SaveAs "C:\Target.xlsx", FileFormat:=51
    End Sub
    

    This will automatically create a new workbook called Target.xlsx with the relevant sheet

提交回复
热议问题