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.
 
I've been working with it. I'm just really new to excel and I'm trying to figure out how to enter it because data validation won't allow the formula because of it's length.
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I believe I manged to work around the length issue but when I enter OB-F1-S1 is won't allow my entry.
 
Upvote 0
I believe I manged to work around the length issue but when I enter OB-F1-S1 is won't allow my entry.

As I mentioned earlier, my previous suggestions do not work.

In the meantime I have worked out a new formula (partly tested, it seems to work with OB-F1-S1 and others):


=IFERROR(IF((LEN(A2)=8)*SUMPRODUCT((ABS(77.5-CODE(UPPER(MID(A2,ROW($1:$8),1))))<13)*MID("99090090",ROW($1:$8),1)+(ABS(52-CODE(MID(A2,ROW($1:$8),1)))<=5)*MID("00009009",ROW($1:$8),1)+(MID(A2,3,1)="-")+(MID(A2,6,1)="-"))=70,"correct","incorrect"),"incorrect")
 
Last edited:
Upvote 0
I've been working with it. I'm just really new to excel and I'm trying to figure out how to enter it because data validation won't allow the formula because of it's length.
Stop trying... the formula is too long for Data Validation (I developed it in a cell and forgot about the length limit on Data Validation formulas). I have managed to shorten the formula, but not enough to satisfy the length limit. I could make the formula short enough if the text in your cells were all of the same case (all upper or all lower case), but with the text being above to be either upper or lower case, I cannot find a way to shorten the formula enough for use in Data Validation. Another possibility is to use VBA event code to monitor the cells and react with a MessageBox if the pattern is incorrect. If you are willing to go that route, you need to tell me the address range of all the cell that would need to be monitored.
 
Upvote 0
As I mentioned earlier, my previous suggestions do not work.

In the meantime I have worked out a new formula (partly tested, it seems to work with OB-F1-S1 and others):


=IFERROR(IF((LEN(A2)=8)*SUMPRODUCT((ABS(77.5-CODE(UPPER(MID(A2,ROW($1:$8),1))))<13)*MID("99090090",ROW($1:$8),1)+(ABS(52-CODE(MID(A2,ROW($1:$8),1)))<=5)*MID("00009009",ROW($1:$8),1)+(MID(A2,3,1)="-")+(MID(A2,6,1)="-"))=70,"correct","incorrect"),"incorrect")
Lightly tested also, but yes, that formula seems to work; however, the OP has said the formula will be used in Data Validation (Message #17), so this modification of your above formula is what the OP would need for that...

=(LEN(A2)=8)*SUMPRODUCT((ABS(77.5-CODE(UPPER(MID(A2,ROW($1:$8),1))))<13)*MID("99090090",ROW($1:$8),1)+(ABS(52-CODE(MID(A2,ROW($1:$8),1)))<=5)*MID("00009009",ROW($1:$8),1)+(MID(A2,3,1)="-")+(MID(A2,6,1)="-"))=70

By the way... nice job coming up with that formula! (y)
 
Last edited:
Upvote 0
The formula in post #25 works like a charm for all the values I've tested so far. Thank you both for your help. Is there any site or book you recommend that I can help me understand data validation formulas better?
 
Upvote 0
So good old fashioned trial and error with help from lovely people like yourselves on forums. Thanks again I will keep on working on other columns hopefully they prove to be easier then this one was.
 
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