macro

  • Thread starter Thread starter kevin carter
  • Start date Start date
K

kevin carter

Hi
we have a macro that runs from a user input
problem is if a user pressess the 'ESC' key it stops the macro
is there any VB code that can catch this ie disable the 'ESC' key while
macro is running


thanks in advance


kevin
 
Kevin,

You catch it by assigning the returned value to a variant, and then
testing the varinat's value:

Dim myVar As Variant
myVar = Application.InputBox("I'm WAITING! Enter Something!")
If myVar = False Then
MsgBox "Cancel or Esc was pressed."
ElseIf myVar = "" Then
MsgBox "You entered nothing, but pressed OK."
Else
MsgBox "You entered: " & myVar
End If

HTH,
Bernie
MS Excel MVP
 
thanks
Bernie Deitrick said:
Kevin,

You catch it by assigning the returned value to a variant, and then
testing the varinat's value:

Dim myVar As Variant
myVar = Application.InputBox("I'm WAITING! Enter Something!")
If myVar = False Then
MsgBox "Cancel or Esc was pressed."
ElseIf myVar = "" Then
MsgBox "You entered nothing, but pressed OK."
Else
MsgBox "You entered: " & myVar
End If

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top