exRP12Nuke
Technical User
Hello,
I am trying to write some code that closes out of Excel when a button is pushed. What I am trying to accomplish is to close the activeworkbook while leaving other workbooks open if there are additional workbooks open at the time that the code is ran; otherwise if the only workbook that is open is the one that I am trying to close, the code will exit out of Excel fully.
Currently what I have is this (simple, I know, but this should be to exit the program):
Basically what I am trying to do is an If/Then statement, but I am unsure of how to write the code with multiple active workbooks.
Thanks!
I am trying to write some code that closes out of Excel when a button is pushed. What I am trying to accomplish is to close the activeworkbook while leaving other workbooks open if there are additional workbooks open at the time that the code is ran; otherwise if the only workbook that is open is the one that I am trying to close, the code will exit out of Excel fully.
Currently what I have is this (simple, I know, but this should be to exit the program):
Code:
Sub Exit_Click()
ThisWorkbook.Close Savechanges:=true
End Sub
Basically what I am trying to do is an If/Then statement, but I am unsure of how to write the code with multiple active workbooks.
Thanks!