validate entry via messagebox

B

Bill Kuunders

I need to be able to ensure that an answer to a message box is either A,a,B
or b
if anything else is entered the macro should display a message and exit the
routine or re-display the message for a new entry.
thanks
Bill K
 
J

JLGWhiz

A Message box does not allow for entry by a user. Assuming you mean InputBox
here is one method:

Response = Application.InputBox("Enter a string". "Alpha Characters", Type:=2)

While this will prevent returning numeric, date, time and other non-string
data types, it does not restrict the entry to alpha characters.

You would need to use scripting to construct a pattern to validate the entry
against.
I am just beginning to work with Scripting and have not developed that
expertise as yet.
 
B

Bill Kuunders

Thanks for that.
I eventually got some code working to go back to the input box if the entry
was not
an A a B or b
Bill
 
Top