Any idea of how to close list of workbooks using VBA ?

xlhelp15

Board Regular
Joined
Sep 12, 2014
Messages
116
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Hello Genius - Is there a way to close list of workbooks using VBA ? Have tried the way of Workbooks("sample1").close but it closed only the sample1 WB. I need to close Sample1, Sample5, Sample12 in a row when I click the command button.

Thank you for considering my request.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Rich (BB code):
Workbooks("Sample1").Close
Workbooks("Sample5").Close
Workbooks("Sample12").Close

If you list them in a row like this, they will all close when you hit the command button
 
Last edited:
Upvote 0
Thank you, Captain.

But it works only when those sample workbooks are in open status.

It needs to close the file if it exists, otherwise no action to perform.

Any help here ?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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