macro

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
 
B

Bernie Deitrick

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
 
K

kevin carter

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
 
Top