Close without saving

L

LoveCandle

Hi everybody,

I have the following code for closing the current workbook withou
saving changes >>

I want it to be developed to close all active workbooks


Code
 
L

Leith Ross

Hello Love Candle,

Copy this code into a VBA module. You can call the macro anytime, and
anywhere you need in your code.


Code:
--------------------

Public Sub CloseAllWorkbooks()

Dim Wkb As Workbook

For Each Wkb In Workbooks
If Wkb.Name <> ThisWorkbook.Name Then
Wkb.Saved = True
Wkb.Close
End If
Next Wkb

With ThisWorkbook
.Saved = True
.Close
End With

End Sub
 
L

LoveCandle

Thank you so much for this perfect code

But, can you develop it more to close excel program completely not only
the active workbooks windows only,
 

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