InputBox buttons
Using vbOK, vbCancel, vbAbort etc. works for the MsgBox function. These are
enumerated (builtin) integer constants (technically type Long) recognized by
VBA. For example:
MsgBox vbOK
MsgBox vbCancel
MsgBox vbAbort
MsgBox vbRetry
MsgBox vbIgnore
InputBox returns a string containing the content of the what was typed in
the textbox or an empty string ("") if the Cancel button was clicked. Same
happens if you don't type anything and click OK, which amounts to the same
thing so this should't be a problem.
Try:
Dim NewHeader as String
NewHeader = InputBox("Specify a header name...")
If NewHeader < "" Then ActiveCell.Value = NewHeader
Greg
"Karen53" wrote:
Hi,
How do I capture the OK or Cancel button on an input box?
I've tried this but I get a type mismatch error...
Dim NewHeader as String
If NewHeader = vbOK Then 'if input box was not cancelled
--
Thanks for your help.
Karen53
|