Hi; I have a macro that uses InputBox for the user to provide data. Once the macro is started you can't stop it until it finishes.
How can I stop the macro using the ESC key or can I assign a key to stop the macro.
Thanks
Hi; I have a macro that uses InputBox for the user to provide data. Once the macro is started you can't stop it until it finishes.
How can I stop the macro using the ESC key or can I assign a key to stop the macro.
Thanks
ctrl+break perhaps?
Thank you that works.
Is there a way to insert a line of code to assign say, the
F4 key or other key combinations to stop the macro?
I would think that your code is writen so that it won't stop until there is an input by the user. Post your code, remember to use Code Tags.
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
This was my first attemp at writing code. These lines are only for the first value. I have 20 additional InputBox statements. The reason for a method to stop the macro is many individuals running the macro and getting interrupted while inputing data.
![]()
Sub Fill01() Worksheets("SINGLE PHASE CONSTRUCTION").Activate Dim UserEntry As String UserEntry = InputBox("What is the W/O #?", "INPUT W/O") If UserEntry <> "" Then Range("B2").Value = UserEntry END SUB
Test UserEntry for "Quit" or something similar.
Try this
![]()
Option Explicit Sub Fill01() 'Worksheets("SINGLE PHASE CONSTRUCTION").Activate Dim UserEntry As String UserEntry = InputBox("What is the W/O #?", "INPUT W/O") Select Case UserEntry Case "": Exit Sub Case Else: Range("B2").Value = UserEntry End Select End Sub
I tested and found that if you provide a "" (blank, no answer) it terminates the macro. That works, but sometimes we need to provide a blank answers so for our application it won't work. I'll pass the word on the Ctrl+Break, key strokes.
Thanks to all for your help.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks