IF Formula Help

jbeer

New Member
Joined
Mar 17, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm trying to create an IF formula that validates employee id's in a spreadsheet.

The criteria is that the numeric numbers can be between 6 and 9 in length but must not contain all of the same numbers like 111111, 222222, 333333 etc..., so I have the below formula but when I enter 111111 it comes back as Valid so this is picking up the 6 numeric in the final part of the formula.

=IF(OR(A1="000000",A1="111111",A1="222222",A1="333333",A1="444444",A1="555555",A1="666666",A1="777777",A1="888888",A1="999999"),"Invalid",
IF(OR(SUM(LEN(A1)-LEN(SUBSTITUTE(A1,{1,2,3,4,5,6,7,8,9,0},)))=6,SUM(LEN(A1)-LEN(SUBSTITUTE(A1,{1,2,3,4,5,6,7,8,9,0},)))=7,SUM(LEN(A1)-LEN(SUBSTITUTE(F8,{1,2,3,4,5,6,7,8,9,0},)))=8),"Valid",
"Invalid"))

Thanks
 

Attachments

  • Excel.png
    Excel.png
    3.2 KB · Views: 6

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi & welcome to MrExcel.
How about
Excel Formula:
=IF(OR(A1+0=REPT(LEFT(A1),LEN(A1))+0,LEN(A1)<6,LEN(A1)>9),"Invalid","Valid")
 
Upvote 0
Hi,

You say the IDs are to be 6 to 9 characters, but didn't specify requirements for the other/remaining 3 characters.
This will Flag consecutive 6 same number anywhere within the ID as Invalid, whether it's All numeric, or Alpha-numeric, and must be 6 to 9 characters to be Valid:

Book3.xlsx
AB
1
21111112Invalid
3027862Valid
42333333Invalid
5122222234Invalid
6123333334Invalid
7123444444Invalid
8132465987Valid
91234Invalid
101234506789Invalid
11122222345Valid
12ABC111111Invalid
13ABCD11111Valid
Sheet844
Cell Formulas
RangeFormula
B2:B13B2=IF(OR(MID(A2,{1,2,3,4},6)=REPT(MID(A2,{1,2,3,4},1),6),LEN(A2)<6,LEN(A2)>9),"Invalid","Valid")
 
Upvote 0
Or, if the IDs Must be All numbers, use C2 formula:

Book3.xlsx
ABCD
1
21111112InvalidInvalid7
3027862ValidValid6
42333333InvalidInvalid7
5122222234InvalidInvalid9
6123333334InvalidInvalid9
7123444444InvalidInvalid9
8132465987ValidValid9
91234InvalidInvalid4
101234506789InvalidInvalid10
11122222345ValidValid9
12ABC111111InvalidInvalid9
13ABCD11111ValidInvalid9
Sheet844
Cell Formulas
RangeFormula
B2:B13B2=IF(OR(MID(A2,{1,2,3,4},6)=REPT(MID(A2,{1,2,3,4},1),6),LEN(A2)<6,LEN(A2)>9),"Invalid","Valid")
C2:C13C2=IF(OR(ISERR(A2+0),MID(A2,{1,2,3,4},6)=REPT(MID(A2,{1,2,3,4},1),6),LEN(A2)<6,LEN(A2)>9),"Invalid","Valid")
D2:D13D2=LEN(A2)
 
Upvote 0
Or, if the IDs Must be All numbers, use C2 formula:

Book3.xlsx
ABCD
1
21111112InvalidInvalid7
3027862ValidValid6
42333333InvalidInvalid7
5122222234InvalidInvalid9
6123333334InvalidInvalid9
7123444444InvalidInvalid9
8132465987ValidValid9
91234InvalidInvalid4
101234506789InvalidInvalid10
11122222345ValidValid9
12ABC111111InvalidInvalid9
13ABCD11111ValidInvalid9
Sheet844
Cell Formulas
RangeFormula
B2:B13B2=IF(OR(MID(A2,{1,2,3,4},6)=REPT(MID(A2,{1,2,3,4},1),6),LEN(A2)<6,LEN(A2)>9),"Invalid","Valid")
C2:C13C2=IF(OR(ISERR(A2+0),MID(A2,{1,2,3,4},6)=REPT(MID(A2,{1,2,3,4},1),6),LEN(A2)<6,LEN(A2)>9),"Invalid","Valid")
D2:D13D2=LEN(A2)

That is great the formula in C2 I think is going to work best for me...I'll test it at work tomorrow and will revert back if I need further help.

Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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