I need to step out of a macro based on a user respone, and I don't know how to end this macro if the user needs to correct a cell entry.
If they respond "no", I want to sub to end and select the cell where the correction needs to be made.
Thanks
Ted
If Dir(filePath, vbDirectory) = vbNullString Then
Dim FolderMsg, ResponseFolder
FolderMsg = "This folder does not exist." & Chr(13) & Chr(13) _
& "Do you want to create a new customer folder?"
ResponseFolder = MsgBox(FolderMsg, vbYesNo + vbInformation)
If ResponseFolder = vbYes Then
MkDir filePath
End If
If ResponseClose = vbNo Then
Dim CustMsg, ResponseCustMsg As String
CustMsg = "Check the customer name." & Chr(13) & Chr(13) _
& "Correct if needed."
ResponseCustMsg = MsgBox(CustMsg, vbOKOnly + vbCritical)
Range("I5").Select
Exit Sub 'THIS IS WHERE I NEED TO EXIT THE MACRO
End If
End If
Rem
Rem http://www.excelforum.com/excel-programming/663085-save-as-and-creating-directory.html
Rem
Rem Save the file in the proper folder
If ActiveWorkbook.FullName = filePath & Application.PathSeparator & namePN & " PrtRev_ " _
& nameRev & " SO_" & nameSO & " ILRev2.xls" Then
Dim DuplicateMsg, ResponseDuplicate
DuplicateMsg = "This file already exists." & Chr(13) & Chr(13) _
& "Do you want to overwrite it?"
ResponseDuplicate = MsgBox(DuplicateMsg, vbYesNo + vbInformation)
If ResponseDuplicate = vbYes Then
ActiveWorkbook.Save
End If
Else
ActiveWorkbook.SaveAs filePath & Application.PathSeparator & namePN & " PrtRev_ " _
& nameRev & " SO_" & nameSO & " ILRev2.xls"
Range("e1") = "serenity now!"
End If
Rem
ActiveWindow.WindowState = xlMaximized
Calculate
Range("F13").Select
Rem ActiveWorkbook.Close
Rem End of loop should go here
Rem Dim CloseMsg, ResponseClose
Rem PrintMsg = "Do you want to close the file?" & Chr(13)
Rem ResponseClose = MsgBox(PrintMsg, vbYesNo + vbInformation)
Rem If ResponseClose = vbYes Then
Rem ActiveWorkbook.Close True
Rem End If
Else
Dim WrongMsg As String
WrongMsg = "This may not be an Inspectional Layout file." & Chr(13) & Chr(13) _
& "This macro will not run on files that are not this type."
MsgBox WrongMsg, vbOKOnly + vbCritical
End If
'
End Sub
Bookmarks