Macro to save only the active worksheet

前端 未结 1 1094
鱼传尺愫
鱼传尺愫 2020-12-21 13:42

In the below code it saves the complete workbook. I want to save only the active worksheet.

Sub sbVBS_To_SAVE_ActiveWorkbook()
ActiveWorkbook.Save
End Sub


        
相关标签:
1条回答
  • 2020-12-21 14:00

    Copying a worksheet to no location automatically creates a new workbook in the foreground with a copy of the worksheet as the only worksheet in the new workbook.

    Sub test()
        worksheets("sheet3").copy
        'there is now a new active workbook
        with activeworkbook
            'save it
            .SaveAs Filename:="some file path and filename without extension", FileFormat:=xlOpenXMLWorkbook
            'optionally close it
            .close savechanges:=false
        end with
    End Sub
    
    0 讨论(0)
提交回复
热议问题