Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
close all open workbooks except the active one
I am sure the answer is very simple, but at the start of a macro, I wish to close all the workbooks that are not the activeworkbook (which contains the macro). Can anyone tell me how. Thanks in advance Dav -- Dav ------------------------------------------------------------------------ Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107 View this thread: http://www.excelforum.com/showthread...hreadid=529987 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
close all open workbooks except the active one
Hi Dav,
This worked on my PC: Sub closeAllOtherWb() Dim wkbWorkbook As Workbook For Each wkbWorkbook In Workbooks If wkbWorkbook.Name < ThisWorkbook.Name Then wkbWorkbook.Close Next wkbWorkbook End Sub -- Stefano Gatto "Dav" wrote: I am sure the answer is very simple, but at the start of a macro, I wish to close all the workbooks that are not the activeworkbook (which contains the macro). Can anyone tell me how. Thanks in advance Dav -- Dav ------------------------------------------------------------------------ Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107 View this thread: http://www.excelforum.com/showthread...hreadid=529987 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
close all open workbooks except the active one
Thanks for your help That works excellently. I knew there would be a simple way, but it was beyond me in finding it. The answer is always simple when you know how! Cheers Dav -- Dav ------------------------------------------------------------------------ Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107 View this thread: http://www.excelforum.com/showthread...hreadid=529987 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
close all open workbooks except the active one
Just pointing out that if changes were made to any of the open workbooks
since the last save, Excel will prompt users to save changes (which comes with a cancel button). It is possible not all workbooks will be closed. You'll need to decide whether or not this is problem depending on who is running the macro and what problems it could cause. "Dav" wrote: Thanks for your help That works excellently. I knew there would be a simple way, but it was beyond me in finding it. The answer is always simple when you know how! Cheers Dav -- Dav ------------------------------------------------------------------------ Dav's Profile: http://www.excelforum.com/member.php...o&userid=27107 View this thread: http://www.excelforum.com/showthread...hreadid=529987 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to close all open workbooks in Excel 2007 | Setting up and Configuration of Excel | |||
Workbooks Close, but window stays open | Excel Discussion (Misc queries) | |||
How to close specific workbook not all active workbooks? | Excel Programming | |||
Open Close workbooks | Excel Discussion (Misc queries) | |||
help with macro to open and close workbooks | Excel Programming |