Macro to save only the active worksheet

我怕爱的太早我们不能终老 提交于 2020-07-14 09:49:08

问题


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:


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


来源:https://stackoverflow.com/questions/48941546/macro-to-save-only-the-active-worksheet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!