String Function

hulaspiro

New Member
Joined
Aug 16, 2019
Messages
2
Here are the sample text:

Input:
1. AbST/1234342
2. Y_sRR/666
3. B.RE/1234

Output:
1. AST
2. YRR
3. BRE

Basically I need a formula to get the first three capital letters before the slash and disregard lowercase and symbols.
 
Is there a way to edit this via normal excel formula without the use of VBA?
Eric has given you one suggestion for that, with some restrictions and also mentioned the CONCAT function.
My suggestion uses the CONCAT function and also has a restriction. That is that you have a maximum of 9 characters before the slash, though my formula can be adjusted for considerably longer strings before the slash if required.

However, I am also interpreting the following as meaning that there could be more (or less) than 3 capital letters before the slash since you used the words "first three".
Also, although none of your sample data contain capitals after the slash, my formula would exclude those whereas Eric's 'may' include them

I need a formula to get the first three capital letters before the slash ...

Anyway, you could give this a try if you have the CONCAT function in your Excel version.

Excel Workbook
AB
1AbST/1234342AST
2Y_sRR/666YRR
3B.RE/1234BRE
4AB45CDEn/123RABC
5ABCDe/55ABC
6SDtr/3eSD
7rrrr/234
8Dr/3DDD
3 capitals



@Eric
Also note that your use of -78 and <14 causes the [ character to be returned as a capital letter. :)
 
Last edited:
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
@Eric
Also note that your use of -78 and <14 causes the [ character to be returned as a capital letter. :)

I was aware! :) There were a few other implicit assumptions in the formula as well, based on the sample data. I figured I'd wait until I got some feedback from the OP as to whether they had CONCAT available before I spent time working on the wrong version.

Here's your formula adapted for unlimited characters before the slash:

=LEFT(CONCAT(IF(ABS(77.5-CODE(MID(A1,ROW(INDIRECT("1:"&FIND("/",A1&"/")-1)),1)))<13,MID(A1,ROW(INDIRECT("1:"&FIND("/",A1&"/")-1)),1),"")),3)

requiring Control+Shift+Enter.
 
Upvote 0
Here's your formula adapted for unlimited characters before the slash:

=LEFT(CONCAT(IF(ABS(77.5-CODE(MID(A1,ROW(INDIRECT("1:"&FIND("/",A1&"/")-1)),1)))<13,MID(A1,ROW(INDIRECT("1:"&FIND("/",A1&"/")-1)),1),"")),3)

requiring Control+Shift+Enter.
Hi Eric/hulaspiro

I would choose a slightly different version if there can be a lot of characters before the slash:

=LEFT(CONCAT(IF(ABS(77.5-CODE(MID(A1,ROW(INDEX(A:A,1):INDEX(A:A,FIND("/",A1))),1)))<13,MID(A1,ROW(INDEX(A:A,1):INDEX(A:A,FIND("/",A1))),1),"")),3)

Still requiring Control+Shift+Enter confirmation.

- Although a little longer, this version is non-volatile
- I haven't bothered with the -1 after FIND("/"..) since the slash will never be counted as a capital anyway
- I have not included the &"/" in these parts FIND("/",A1&"/") as I would prefer to return an error (or use IFERROR to return something else) rather than "ABC" for an example like "ABCd2" as "ABC" does not meet (to me anyway) the requirement of "the first three capital letters before the slash"
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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