robinJ
robinJ

Reputation: 45

Excel VBA code to SaveAs a specific filename and close the active workbook

What VBA code do I need to add to the end of an existing sub to save the active workbook as "finaloutput.xls" and then automatically close the workbook without saving changes?

Upvotes: 1

Views: 40819

Answers (1)

Mike Woodhouse
Mike Woodhouse

Reputation: 52316

You could use something as simple as this, which I put in another workbook and executed from the Tools...Macros menu (Alt+F8) after activating the workbook to be saved.

Public Sub SaveAsAndClose()

    ActiveWorkbook.SaveAs "finaloutput.xls"
    ActiveWorkbook.Close

End Sub

Upvotes: 7

Related Questions