Data Validation number with leading zero

kashif.special2005

Active Member
Joined
Oct 26, 2009
Messages
443
Hi,

I applied data validation in a cell that, the value should be number and should be 9 digits.

Data validation formula:

=AND(ISNUMBER(C5),LEN(C5)=9)

But the problem is, it is not accepting 9 digits with leading 0.

like,

Working:- 123456789
Not working:- 012345678

I want to accept, if I enter 9 digits with 0.

Please help to me resolve this problem

Thanks
Kashif
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
The issue is that a leading 0 means nothing to actual numbers, and are dropped upon entry, even if you have custom formatting to show the leading zero. Data Validation looks at what is actually in the cell, not how it is formatted. To see what is actually in the cell, select it and see what shows up in the formula bar.

If you want to maintain leading zeroes, this cell will need to be formatted as Text, not as any number or custom number format. You can still do that and apply the Data Validation you want with a minor tweak:
=AND(ISNUMBER(C5+0),LEN(C5)=9)

By adding zero, the entry is converted from Text to numeric for the sake of that part of the validation.
 
Upvote 0
You are most welcome. Glad to help!
:)
 
Upvote 0

Forum statistics

Threads
1,225,313
Messages
6,184,222
Members
453,223
Latest member
Ignition04

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
Back
Top