I have the sub below called from a button for a workbook called 'Events' and when the button is clicked the workbook is saved, this all works fine up to this point.
What I want it to do is check if there any other non related workbooks currently open and it there wasn't for it to close the 'Events' workbook and quit Excel completely and if there were other non related workbooks open to just close the 'Events' workbook and and any others would remain open by just using
.
The issue I'm having is whilst testing this sub when its the only workbook open it just closes thr workbook Not the workbook and Excel.
I'm sure its something to do with perhaps the order I have the code in but even after changing it around it still won't work.
Anyone got any suggestions on whats wrong and how to resolve it?
Thanks Paul
What I want it to do is check if there any other non related workbooks currently open and it there wasn't for it to close the 'Events' workbook and quit Excel completely and if there were other non related workbooks open to just close the 'Events' workbook and and any others would remain open by just using
VBA Code:
ActiveWorkbook.Close SaveChanges:=True
The issue I'm having is whilst testing this sub when its the only workbook open it just closes thr workbook Not the workbook and Excel.
I'm sure its something to do with perhaps the order I have the code in but even after changing it around it still won't work.
Anyone got any suggestions on whats wrong and how to resolve it?
Thanks Paul
VBA Code:
Sub ExitWB()
Dim wbCount As Integer
ActiveWorkbook.Close SaveChanges:=True
wbCount = Workbooks.Count - 1
If wbCount = 0 Then
Application.Quit
End If
End Sub