Check for typing errors in cells

KyleG

Well-known Member
Joined
Jun 12, 2004
Messages
623
I am trying to find a way (macro) to ensure that the data in cells on a worksheet are correct.

The only data that will be entered are:
negative numbers eg. -1.40
Positive numbers eg. 1.40
Cells with the text n/a
Blank Cells.

We have had a few instances where people have accidently entered incorrect characters eg.
1..40
1.40.
n

All of these cause errors in formulas that are running on another worksheet. Is there a way that a have a macro check that only correct values are entered and gives the user a warning if they incorrectly type something?

Thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi,

My first idea would be to use data validation.
Choose "custom" and try this formula (while A1 is active): =OR(ISNUMBER(A1),A1="n/a")

You will only be able to fill in numerics or "n/a".
If you fill in the alertmessage, the user will be warned why the entry is not accepted. No code needed.

kind regards,
Erik
 
Upvote 0

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Select that cell E9 here:

Excel Toolbar: Data - Validation..
Settings [Tab]

Allow:
Custom

Formula Is:

=Or(E9="n/a",E9="N/A",E9="",IsNumber(E9))
 
Upvote 0

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi, Joe,

It works for me without repeating the string Lower & Upper Case.
Data validation is not casesensitive.

best regards,
Erik
 
Upvote 0

KyleG

Well-known Member
Joined
Jun 12, 2004
Messages
623
Thanks heaps thats exactly what i needed and no code required very cool.
 
Upvote 0

Forum statistics

Threads
1,190,637
Messages
5,982,055
Members
439,752
Latest member
jscratch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top