Formula for CF that will look at ONLY the first 6 characters in a string

MFish

Board Regular
Joined
May 9, 2019
Messages
76
Hi,

My code I currently have...

Code:
=IF(OFFSET(A8,0,1)=OFFSET(A8,-1,1),OFFSET(A8,-1,0),OFFSET(A8,-1,0)+1)

Basically if the value in the cell next to it is the same as the one above then the value of the cell the formula is in, it'll be the same number correlating to the one above... Makes it easier for me to run a conditional format for unique ID's. Now, this is great and all but I ran into a barrier... I'd like for this formula to ONLY read the first 6 characters in the string. They will always go...

X = Letter
- = -
1 = Number

XXX-11

Reason why I need it to read the first 6 characters is because I'm going to concatenate two cells together to make it like XXX-11 X. I just need it to read the first string of 6 characters to tell me if it's similar.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
@MFish

A bit of a longwinded CF formula but maybe...

Code:
=AND(CODE(MID(G1,1,1))>=65,CODE(MID(G1,1,1))<=90,CODE(MID(G1,2,1))>=65,CODE(MID(G1,2,1))<=90,CODE(MID(G1,3,1))>=65,CODE(MID(G1,3,1))<=90,MID(G1,4,1)="-",CODE(MID(G1,5,1))>=48,CODE(MID(G1,5,1))<=57,CODE(MID(G1,5,1))>=48,CODE(MID(G1,5,1))<=57)


Excel 2010
G
1XXX-11fgrt543
2ABC-94
3X2XX-11fgrt545
4123- 23
5XYZ-63
Sheet C

Hope that helps.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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