Close without saving

  • Thread starter Thread starter LoveCandle
  • Start date Start date
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
 
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
 
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,
 
Back
Top