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

Detectiveclem

Active Member
Joined
May 31, 2014
Messages
315
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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

jmacleary

Well-known Member
Joined
Oct 5, 2015
Messages
1,056
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
Hi there

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

Detectiveclem

Active Member
Joined
May 31, 2014
Messages
315
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
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.
 

Detectiveclem

Active Member
Joined
May 31, 2014
Messages
315
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Hi, Thank you, but I wanted to keep it ideally as a number
 

jmacleary

Well-known Member
Joined
Oct 5, 2015
Messages
1,056
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
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.
 

Forum statistics

Threads
1,147,452
Messages
5,741,206
Members
423,648
Latest member
steel1968

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