Close all other open Workbooks

C

CLR

Hi all..........

Need code if you please to close all other open workbooks except the one I'm
running the macro in. I do not know what their names are.

TIA
Vaya con Dios,
Chuck, CABGx3
 
B

Barb Reinhardt

Try something like this

Dim WB as Workbook

For each WB in Application.Workbooks
if wb.name <> thisworkbook.name then
WB.Close 'You may want to save or do something else here
end if
next WB
 
G

Gary''s Student

Sub clr()
nm = ThisWorkbook.Name
Dim w As Workbook
For Each w In Workbooks
If w.Name = nm Then
Else
w.Close
End If
Next
End Sub
 
C

CLR

Thanks Barb.......
Appreciate the quick comeback.........

Vaya con Dios,
Chuck, CABGx3
 
C

CLR

Thanks Gary"s Student....
Appreciate the quick comeback

Vaya con Dios,
Chuck, CABGx3
 

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