vba application.quit not working for me completly. why?

aedctalk

Board Regular
Joined
Oct 9, 2010
Messages
156
This is what I am using:

Code:
'// Exit Everything... Save? No Not Needed....
    
    Application.DisplayAlerts = False
    ActiveWorkbook.Close

    If Application.Workbooks.Count = 1 Then
        
    Application.Quit
        
    End If

If mutiple workbooks are open I just want it to close this one workbook

If only one workbook is open then i want it to close the workbook and exit the excel. The issue i'm having is that if only one workbook is open it does exit the workbook.. but it leaves me in excel with the grey background.. so pretty much my application.quit doesnt seem to be working if only one workbook is open. Any idea on whats wrong?
 
If you only have one workbook open and you close the active workbook then you will have 0 workbooks open.

So Application.Quit will never get executed.
 
Upvote 0
Try this...

Code:
'// Exit Everything... Save? No Not Needed....
    
    Application.DisplayAlerts = False
    

    If Application.Workbooks.Count = 1 Then
        
        Application.Quit
        
    Else
    
        ActiveWorkbook.Close
        
    End If
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top