![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: Manitoba, Canada
Posts: 22
|
I have a macro that calls up a series of about 12 inputboxes. The first inputbox opens, waits for me to type the numbers, I press enter, and then it goes to another cell and the next inputbox opens up, etc. The problem I have is that there is no way for me to stop or cancel the macro between the different inputboxes (before the "Range.Select" is executed.) Is there a way of pressing the ESC key to stop or cancel the macro? Here is part of the code for the macro:
Range("B4").Select MyNum2 = Application.InputBox(Prompt:="REGULAR HOURS", Title:="HOURS OF WORK", Default:="80", Type:=1) ActiveCell.FormulaR1C1 = MyNum2 CANCEL HERE Range("C4").Select MyNum3 = Application.InputBox(Prompt:="TIME AND ONE HALF HOURS", Title:="HOURS OF WORK", Default:="4", Type:=1) ActiveCell.FormulaR1C1 = MyNum3 or CANCEL HERE etc. Thanks for any help Peter [ This Message was edited by: Mood on 2002-03-14 09:21 ] |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Quote:
ActiveCell.FormulaR1C1 = MyNum2 and Range("C4").Select would be almost instant. The way to exit a sub is to use Exit Sub If you want to exit the procedure if the user presses Cancel on the inputbox is to use this:- MyNum2 = Application.InputBox(Prompt:="REGULAR HOURS", Title:="HOURS OF WORK", Default:="80", Type:=1) If CStr(MyNum2)="False" Then Exit Sub HTH, D |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Location: Manitoba, Canada
Posts: 22
|
Thank you, D. It did help. Works perfectly.
Peter |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|