G
Guest
I have a button whose click event invokes 2 Input Boxes. The input boxes ask
the user for the first and last name of a person. The input boxes have an OK
and a Cancel button on them.
If the user clicks on either of the Cancel buttons, I want the programming
to stop and place the cursor in a specified cell.
I tried to do this on my own, but I haven't had any success. With or
without my "Cancel" coding, the sub runs in it's entirety and creates a name
in my list with just a comma in it.
How do I get the Cancel button click (whether it is the first input box or
the second input box) to discontinue running the macro and move the user's
cursor to cell AG3?
Here is the coding I have written so far:
If CommandButtonAddForeman.Caption = "Cancel" Then EndRoutine
Dim AnswerForemenFirst As String
Dim AnswerForemenLast As String
AnswerForemenFirst = InputBox("What is the Foreman's first name?",
"Add a new Foreman")
AnswerForemanLast = InputBox("What is the Foreman's last name?",
"Add a new Foreman")
Application.Goto Reference:="markerforemanadd"
ActiveCell.Value = "zzzzzz"
Selection.EntireRow.Insert
ActiveCell.Value = AnswerForemanLast + ", " + AnswerForemenFirst
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=RC[-1]"
Application.Goto Reference:="ForemenToSort"
Selection.Sort Key1:=Range("SortRangeColumn"), Order1:=xlAscending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Application.Goto Reference:="markerforemanadd"
ActiveCell.Value = " "
Range("A1").Select
Range("AG3").Select
Private Sub EndRoutine()
Range("AG3").Select
End
End Sub
Thanks for any help you can offer.
Tofer
the user for the first and last name of a person. The input boxes have an OK
and a Cancel button on them.
If the user clicks on either of the Cancel buttons, I want the programming
to stop and place the cursor in a specified cell.
I tried to do this on my own, but I haven't had any success. With or
without my "Cancel" coding, the sub runs in it's entirety and creates a name
in my list with just a comma in it.
How do I get the Cancel button click (whether it is the first input box or
the second input box) to discontinue running the macro and move the user's
cursor to cell AG3?
Here is the coding I have written so far:
If CommandButtonAddForeman.Caption = "Cancel" Then EndRoutine
Dim AnswerForemenFirst As String
Dim AnswerForemenLast As String
AnswerForemenFirst = InputBox("What is the Foreman's first name?",
"Add a new Foreman")
AnswerForemanLast = InputBox("What is the Foreman's last name?",
"Add a new Foreman")
Application.Goto Reference:="markerforemanadd"
ActiveCell.Value = "zzzzzz"
Selection.EntireRow.Insert
ActiveCell.Value = AnswerForemanLast + ", " + AnswerForemenFirst
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=RC[-1]"
Application.Goto Reference:="ForemenToSort"
Selection.Sort Key1:=Range("SortRangeColumn"), Order1:=xlAscending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Application.Goto Reference:="markerforemanadd"
ActiveCell.Value = " "
Range("A1").Select
Range("AG3").Select
Private Sub EndRoutine()
Range("AG3").Select
End
End Sub
Thanks for any help you can offer.
Tofer