Message box code

ftsang

New Member
Joined
Jun 9, 2005
Messages
25
Hi guys,
I have a message box for a macro which says "Please pick a number".
Now, I have a list of pre-defined numbers which I wish the user to pick (which are in no sequential order, and there are about 3000 of them). I want the message box to say something like "please pick a valid number" and return to the "enter a number" message box if the user does not enter a number in my list. Help is greatly appreciated!

Thanks, Merry Xmas!

Frank
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

ftsang

New Member
Joined
Jun 9, 2005
Messages
25
Unfortunately because there are about 3000 different cases, it would take too long to write a Case Is = statement or an else if statement for each one, so those 2 methods do not help.

Plus the numbers change on a weekly basis (but are listed within the excel workbook). I do not really want to use a drop down list, is there a way to code it so that if a number entered in the inputbox is not in this list, it will redirect me to the input box?
 

Seti

Well-known Member
Joined
May 19, 2002
Messages
2,916
How about using data validation on the cell instead?

You could use a dynamic named range for the choice list, then if someone inputs an invalid number (not in the list) you could use the data validation Error Alert notice to handle it.
 

ftsang

New Member
Joined
Jun 9, 2005
Messages
25
Hiya,
Thanks for the help, I want to give users the options of a) using a drop down list (and using validation), or, if they know the number, I want them to be able to type it in and use the macro, but have the code to notify them of any typo's they may enter!

Is this possible??
 

Watch MrExcel Video

Forum statistics

Threads
1,119,127
Messages
5,576,244
Members
412,709
Latest member
Rishu
Top