Here I am going to give an idea how we can save and close the current excel sheet using Macro. This function can be written in the Module and can be called any where in the program where we want to save the Excel and Close it. The below code will save and close only the Workbook where the code is running.


Sub SaveClose()
Dim Wb As Workbook
For Each Wb In Workbooks
If Wb.Name <> ThisWorkbook.Name Then
Wb.Close savechanges:=True
End If
Next Wb
ThisWorkbook.Close savechanges:=True
End Sub

Note: Above code will save and close the only workbook, which you have selected; It means where you are running this macro.


Join over 10, 000+ Excel VBA Enthusiasts & get this FREE e-Book Now!