Data Validation Formula - End in 7 Numbers

tomexcel1

New Member
Joined
Feb 22, 2018
Messages
47
Hi All

I've been trying to rack my brain for ages just cant work out how to use a formula to force user to end entry with 7 numbers. (Case of the letters is not important)

For example these should be ok:

Hill J 1234567
Joe R 1345647
Smith 9864567

These should fail:

Hill J
Smith
Joe R 123

Thanks in Advance
Tom
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
In this example, I'm using Column A, change as necessary.

Data Validation>Custom
=ISNUMBER(RIGHT(A1,7)+0)
 
Upvote 0
In this example, I'm using Column A, change as necessary.

Data Validation>Custom
=ISNUMBER(RIGHT(A1,7)+0)
That was my first thought but if there is a space before a 6 digit number it still returned TRUE

try

Code:
=AND(ISNUMBER(--RIGHT(A1,7)),LEN(SUBSTITUTE(RIGHT(A1,7)," ",""))=7)

Now that I think about there is nothing stopping the user from entering more then 7 digits. If that is a problem then try
Code:
=AND(ISNUMBER(--RIGHT(A1,7)),LEN(SUBSTITUTE(RIGHT(A1,7)," ",""))=7,NOT(ISNUMBER(--LEFT(RIGHT(A1,8),1))))
 
Last edited:
Upvote 0
For the 2 scenarios presented by Scott:

6 numbers with a space in front, use:

=LEN(RIGHT(A1,7)+0)=7

6 numbers with a space And/or more than 7 numbers, use:

=AND(LEN(RIGHT(A1,7)+0)=7,LEN(RIGHT(A1,8)+0)<>8)

A little simpler.

BTW, The ISNUMBER test is Not needed (like my post # 3), any number evaluates to TRUE, any Error evaluates to FALSE.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,108
Members
452,544
Latest member
aush

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