ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   validate entry via messagebox (https://www.excelbanter.com/excel-programming/417167-validate-entry-via-messagebox.html)

Bill Kuunders

validate entry via messagebox
 
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



JLGWhiz

validate entry via messagebox
 
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.




"Bill Kuunders" wrote:

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




Bill Kuunders

validate entry via messagebox
 
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

"JLGWhiz" wrote in message
...
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.




"Bill Kuunders" wrote:

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







All times are GMT +1. The time now is 11:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com