Closing down all open files within Excel

Matt

Board Regular
Joined
Feb 16, 2002
Messages
212
Is there a line of code that will close all files open at the present time in excel rather than writing code to close each seperate workbook?

thanks

Matt
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
In Excel, holding down the shift key when selecting 'File' from the menu produces a 'Close All' option.

In code, you can do,

Workbooks.Close
 
Upvote 0
To add onto codger's code, try application.displayalerts=false before workbooks.close. This will turn off the save box.
 
Upvote 0
Thanks Codger, I was trying to specify workbooks("*.*").close and hence failed dismally. Interesting holding the shift key down and then going to the file menu - haven't seen that before! Any other interesting variations that add buttons to the standard menus?
 
Upvote 0
Open experimentation has yielded only shift+edit for copy and paste picture. That's useful for capturing screenshots and passing them around in spreadsheets (like from IT challenged users in an email).

One use for the close all is the ability to save hidden workbooks; elsewise you (more or less) have to exit before you're given the chance to save them.
 
Upvote 0

Forum statistics

Threads
1,214,413
Messages
6,119,372
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top