alpha numeric format with dashes

taliapaw

New Member
Joined
Sep 14, 2016
Messages
16
Hi I'm trying to obtain this format TT-T#-T# and I'm using this formula but when I tested it failed to follow the pattern in text and numbers, it only kept the 2 dash 2 dash 2 format.

=AND(ISTEXT(LEFT(F1,2)),MID(F1,3,1)="-",ISTEXT(MID(F1,4,1)),ISNUMBER(MID(F1,5,1)*1),MID(F1,6,1)="-",ISTEXT(MID(F1,7,1)),ISNUMBER(MID(F1,8,1)*1),LEN(F1)=8)

Any suggestions or help would be greatly appreciated, thank you in advance.
 
If this is a validation, test this formula:

=IF((LEN(F1)=8)*(LEFT(F1,1)>="A")*(MID(F1,2,1)>="A")*(MID(F1,3,1)="-")*(MID(F1,4,1)>="A")*AND(MID(F1,5,1)<"A",MID(F1,5,1)<>"-")*(MID(F1,6,1)="-")*(MID(F1,7,1)>="A")*AND(MID(F1,8,1)<"A",MID(F1,8,1)<>"-")=1,"correct","incorrect")
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
if this is a validation, test this formula:

=if((len(f1)=8)*(left(f1,1)>="a")*(mid(f1,2,1)>="a")*(mid(f1,3,1)="-")*(mid(f1,4,1)>="a")*and(mid(f1,5,1)<"a",mid(f1,5,1)<>"-")*(mid(f1,6,1)="-")*(mid(f1,7,1)>="a")*and(mid(f1,8,1)<"a",mid(f1,8,1)<>"-")=1,"correct","incorrect")

sorry, the formula still needs correcting! Do not use it!
 
Upvote 0
sorry, the formula still needs correcting! Do not use it!
Maybe this...

=NOT(ISNUMBER(0+LEFT(A1,1)))*NOT(ISNUMBER(0+MID(A1,2,1)))*NOT(ISNUMBER(0+MID(A1,4,1)))*NOT(ISNUMBER(0+MID(A1,7,1)))*(MID(A1,3,1)&MID(A1,6,1)="--")*ISNUMBER(0+(MID(A1,5,1)&RIGHT(A1)))*(LEN(A1)=8)
 
Upvote 0
Maybe this...

=NOT(ISNUMBER(0+LEFT(A1,1)))*NOT(ISNUMBER(0+MID(A1,2,1)))*NOT(ISNUMBER(0+MID(A1,4,1)))*NOT(ISNUMBER(0+MID(A1,7,1)))*(MID(A1,3,1)&MID(A1,6,1)="--")*ISNUMBER(0+(MID(A1,5,1)&RIGHT(A1)))*(LEN(A1)=8)

Hi Rick,

When I loaded the formula, excel immediately asked for permission to modify the formula, and when I clicked yes, it worked quite correctly for the data provided.
I can not find what excel modified.

At me, the formula gives "1" for this: (A-t6-t6
 
Upvote 0
Hi Rick,

At me, the formula gives "1" for this: (A-t6-t6
Yeah, it turns out that NOT(ISNUMBER(... is not a sufficient test... back to the drawing boards (really annoying as this is soooo easy to do in VB).
 
Last edited:
Upvote 0
Yeah, it turns out that NOT(ISNUMBER(... is not a sufficient test... back to the drawing boards (really annoying as this is soooo easy to do in VB).
This formula should work correctly though (he says with fingers crossed)...

=(MAX(ABS(CODE(LEFT(UPPER(F1)))-77.5))<13)*(MAX(ABS(CODE(MID(UPPER(F1),2,1))-77.5))<13)*(MID(F1,3,1)="-")*(MAX(ABS(CODE(MID(UPPER(F1),4,1))-77.5))<13)*(MAX(ABS(CODE(MID(UPPER(F1),5,1))-52.5))<5)*(MID(F1,6,1)="-")*(MAX(ABS(CODE(MID(UPPER(F1),7,1))-77.5))<13)*(MAX(ABS(CODE(RIGHT(UPPER(F1)))-52.5))<5)*(LEN(F1)=8)
 
Upvote 0
Sorry for my tardy reply. the formula will be used in data validation.

As for István's suggestion it did not work using 52,5 and 77,5 it gave me an error when I entered it into the data validation about not trying to type a formula.
 
Upvote 0
Sorry for my tardy reply. the formula will be used in data validation.

As for István's suggestion it did not work using 52,5 and 77,5 it gave me an error when I entered it into the data validation about not trying to type a formula.
Which formula are you referring to? What message number was it in?
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,795
Members
451,589
Latest member
Harold14

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