How to interrupt a VBA macro stuck in an InputBox loop?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,525
Office Version
  1. 365
Platform
  1. Windows
I can't post the exact code because its stuck in an InputBox loop. This is close to what it is. I mistakenly put the IsNumeric right after the InputBox, which catches both Cancel so there is no way to exit. How can I interrupt it? Thanks

VBA Code:
Do
  vReply = InputBox(Time & " " & LastAction & vbCrLf & vbCrLf & Prompt, MyName, , 11000, 7000)
  'Cancel returns "", but so does "", so confirm both
  If Not IsNumric(vReply) Then GoTo BadInput

  . . .
 
BadInput:
  MsgBox "Invalid data", vbOKOnly, MyName
Continue:
Loop
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
On your keyboard, press CTRL+BREAK. You should then be able to End the code execution.
I tried that. At least, I think I did. I have a stupid SurfaceBook. It does not have a Break key, but I think Windows+r is break. It doesn't interrupt the macro.

It's stuck in that tight InputBox loop. If I press Win+r while the InputBox prompt is open, nothing happens. If I enter anything else, it puts the prompt back up too quickly for me to do anything.
 
Upvote 0
Try the 'ESC' key multiple times.
It treats Esc just like Cancel. It just puts the InputBox back up. I tried hitting Esc as fast as I could.

Win+r pops up the Run dialog. Is therwe a command I can enter there?
 
Upvote 0
There are many you could try:

Ctrl+FN+B
Ctrl+FN+C
Windows+Esc

Can I ask why you can't just quit the script & redo the code?
 
Upvote 0
There are many you could try:

Ctrl+FN+B
Ctrl+FN+C
Those do nothing

Windows+Esc
That is treated the same as Cancel or Enter. It puts up the Invalid Data msg.

Can I ask why you can't just quit the script & redo the code?
How do I do that?

PS: I have the VBA editor open. Does that make a difference?
 
Upvote 0
1) CTRL+ALT+DEL ... close Excel
2) Sledgehammer approach ... Remove Power cord and battery, Reinsert battery & power cord ... wait for device to reload
 
Upvote 0
1) CTRL+ALT+DEL ... close Excel
That would close Excel, but I am afraid I'll lose the last edits I made to the macro since saving it.

2) Sledgehammer approach ... Remove Power cord and battery, Reinsert battery & power cord ... wait for device to reload
I don't have to go to all that trouble. I can click Windows logo | Power | Power off or Restart. But I was hoping to be able to save the macro code changes. If I have to, I have to. But I'd like to find another way...
 
Upvote 0
Well you can lose the last edits or stay stuck in an infinate loop where you can't do anything.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,730
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top