Data validation restricted to text lenght to 8 - but to include any leading zeros

Detectiveclem

Active Member
Joined
May 31, 2014
Messages
320
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Hi

I am trying to ensure that a range of excel cells shows exactly 8 digits. This part is appears to be easy by using Data Validation to set Text lenght to equal to 8. However as some of the numbers include one or two leading zeros which I need to show this data validation shows it as an error as it only appears to count the numbers and not the zeros.

Can anyone assist so that the error only shows only if less or more than 8 digits appear, including the two leading zeros.

Thank you.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi there

If you change the format of the cells to Text, the leading zeros will be included.
 
Upvote 0
Hi ,

I aleady did this, however when I restrict the text lenght if I type in 00123456 it works, but if I type in 001234567 I get 01234567 without warning me that I have typed in 9 digits.
 
Upvote 0
Hi, Thank you, but I wanted to keep it ideally as a number

If this was in response to my suggestion, then you can keep it looking like a number (with the leading zeroes retained) by formatting the cells as Text and horizontal alignment to the right. It will still perform as a number if you use it in a formula.
 
Upvote 0

Forum statistics

Threads
1,214,382
Messages
6,119,194
Members
448,874
Latest member
Lancelots

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