View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default How to activate InputBox Cancel Function

check out the inputbox method in vb help

Option Explicit
Sub test()
Dim result As String
result = Application.InputBox("Enter String", "Test", , , , , , 2)
If result = False Then
MsgBox "cancel pressed"
Exit Sub
Else
MsgBox result
End If
End Sub

--


Gary


"Chua" wrote in message
...
I use InputBox to display a simple dialog box so that User can enter
information to be used in a macro. The dialog box has an OK button and a
Cancel button. How do I activate the Cancel button to perform the function
that I want?

I tried below code but it will do nothing and exit the program even when
User click the OK button.

a = InputBox ("Enter Password to Proceed:")

If vbCancel = True Then
Do nothing
End If

If a < "12345" Then
MsgBox "INVALID PASSWORD !!!" & vbNewLine & "You have no administrator
rights to access the function.", vbCritical

End
End If