LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Cancel Button Routine

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vb cancel button kckar[_8_] Excel Programming 2 April 17th 06 02:39 PM
Cancel button to cancel the whole macro excelnut1954 Excel Programming 3 January 17th 06 08:27 PM
how do I make a routine run after the 'cancel' butten is pressed . Dave Excel Programming 13 January 10th 05 05:40 PM
Cancel button IamHaxer Excel Programming 3 June 24th 04 05:19 PM
Cancel Button Matt Excel Programming 3 February 3rd 04 11:23 PM


All times are GMT +1. The time now is 01:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"