Frank Melan
Technical User
I am currently using VBA code to close excel, rather than several steps. Originally the code worked as expected. Now it closes but gives this error code. "Microsoft Excel has stopped working. A problem caused the program to stop working correctly. Please close the program. Here is the current codes. Code #1 closes excel when not on the home page.
Code #2 closes excel from the home page.
I am hoping that you Geniuses, can figure out what is happening & how to fix it. This old boy is at wits end with this particular batch of code.
Code:
Sub Exit_Referals()
Dim MsgBoxResult As Long
MsgBoxResult = MsgBox("Would you like to Exit the Referral Workbook?" & vbCr, _
vbYesNo)
If MsgBoxResult = vbNo Then
Exit Sub
ElseIf MsgBoxResult = vbYes Then
Sheets("TOC").Select
Application.Quit
Workbooks.Close
End If
End Sub
Code:
Sub TOC_Exit_Referals()
Dim MsgBoxResult As Long
MsgBoxResult = MsgBox("Would you like to Exit the Referral Workbook?" & vbCr, _
vbYesNo)
If MsgBoxResult = vbNo Then
Exit Sub
ElseIf MsgBoxResult = vbYes Then
Application.Quit
Workbooks.Close
End If
End Sub