View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Stefano Gatto Stefano Gatto is offline
external usenet poster
 
Posts: 59
Default 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