Close all inactive workbooks without saving

  • Thread starter Thread starter Basta1980
  • Start date Start date
B

Basta1980

Hi,

Anyone knows how close all inactive workbooks without saving and thus having
just one workbeek (the active)?!

Thnx
 
Hello

Dim wWorkb As Workbook
For Each wWorkb In Application.Workbooks
If wWorkb.Name <> ActiveWorkbook.Name Then wWorkb.Close (False)
Next wWorkb

HTH
Cordially
Pascal
 
This should work:

Sub CloseAll()
Dim WkbkName As Object
On Error GoTo Close_Error
For Each WkbkName In Application.Workbooks()
If WkbkName.Name <> ThisWorkbook.Name Then WkbkName.Close
savechanges:=False
Next
Close_Error:
Resume Next
End Sub
 

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

Back
Top