can be done as under, two options: In 2nd option, Excel is closed.
Sub closing()
ThisWorkbook.Activate
For Each Window In Application.Windows
If Not Window.Index = ActiveWindow.Index Then
Window.Close Savechanges:=True
End If
Next Window
ThisWorkbook.Close Savechanges:=True
End Sub
OR
Sub quitting()
For Each w In Application.Workbooks
w.Save
Next w
Application.Quit
End Sub
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.