Close all workbooks and keep excel running

S

Scott Hutslar

Is there a way to close all workbooks without exiting excel? I have found
where you can exit excel and it will close all workbooks. I have a scenario
where it is desirable to close all open workbooks and keep excel running.

Anyone know of a way of doing this without closing each workbook individually?
 
T

Tim879

You can use this macro:
Sub Close_All_Open_Workbooks()
Dim I

For I = 1 To Application.Workbooks.Count
Application.Workbooks(I).Close
Next

End Sub
 
S

Scott Hutslar

Thanks for the reply Tim. This is a good way of doing this if we create a
global macro for all users to execute. Is there a way provided by Excel for
an end user to do this? I guess I am looking for a Ribbon path for doing
this.
 
T

Thomas [PBD]

Scott,

Does File>Close not work for this purpose? It will close all open Workbooks
and leave the Excel application open.
 
S

Scott Hutslar

Thanks Thomas. Close just closes the current (active) workbook. But your
suggestion prompted me to customize my tool bar and add a "Close All" button.
This can be found in the commands "Not in the Ribbon".

Thanks everyone for your help!

Thomas said:
Scott,

Does File>Close not work for this purpose? It will close all open Workbooks
and leave the Excel application open.

--
--Thomas [PBD]
Working hard to make working easy.


Scott Hutslar said:
Thanks for the reply Tim. This is a good way of doing this if we create a
global macro for all users to execute. Is there a way provided by Excel for
an end user to do this? I guess I am looking for a Ribbon path for doing
this.
 
G

Gord Dibben

In earlier versions CTRL + w closed all workbooks but user is asked about
saving.


Gord Dibben MS Excel MVP
 

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.

Ask a Question

Top