Extract a particular characters from a cell

DQ2013

New Member
Joined
Nov 7, 2013
Messages
31
Hi Can some one please help me on the following. I have the following data , I only require the first letter after the 2nd dash if the letter is L or R or S and if the length of the characters after the second dash is 4

DataRequire
BW1550T-NAV-L084L
BW1550T-NAV-L089L
BW1550T-NAV-R097R
BW1550T-NAV-R102R
BW1550T-NAV-S117S
BW1550T-NAV-S122S
CFPR180-CS
CFPR180-DM
CFPR180
DTW1150-NAV-ZBULK
DTW1150-NAV-12
DTW1150-NAV-14
GFPR100-CS
GFPR100-DM
GFPR105-CS
GFPR105-DM
BW1550T-NAV-R097R
BW1550T-NAV-S117S
DS2166T1-O/N-AXXS
DS2166T1-O/N-BXS
DS2166T1-O/N-CS
DS2166T1-O/N-DM
DT1138T-NAV-R127R
DT1138T-NAV-S087S
DT1138T-NAV-S092S
DT1138T-NAV-S097S
DT1138T-NAV-S102S
DT1138T-NAV-S107S

<colgroup><col><col></colgroup><tbody>
</tbody>
 
I believe this slightly shorter formula will also work...
That comes back partly to the interpretation of "characters after the second dash" per my previous post.

It also produces an error for the OP's sample data
CFPR180

.. and, if more than 2 dashes are possible, produces an incorrect result (by my interpretation) for
X-4-LBBB-G

The OP seems satisfied.
 
Last edited:
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
:confused: The length of the characters after the second dash is 4 for this...

X-4-L-GG
Literally speaking, yes. But if dash is a delimiter, I see that after the 1st dash there is 1 character, after the 2nd is 1 character etc. The OP seems satisfied.
 
Upvote 0
It also produces an error for the OP's sample data

CFPR180
This fixes the above problem...

=IF(AND(FIND("-",A13&"--",FIND("-",A13&"-")+1)<LEN(A13)-3,OR(MID(TRIM(A13),LEN(TRIM(A13))-4,2)={"-L","-R","-S"})),LEFT(RIGHT(TRIM(A13),4)),"")



.. and, if more than 2 dashes are possible, produces an incorrect result (by my interpretation) for
X-4-LBBB-G
:confused: The OP said "...and if the length of the characters after the second dash is 4"... there are more than 4 characters after the second dash, so I interpret the OP's request as being that nothing should be displayed for it (your formula displays the "L").
 
Last edited:
Upvote 0
This fixes the above problem...

=IF(AND(FIND("-",A13&"--",FIND("-",A13&"-")+1)
I forgot about the HTML translator... here is the full formula...


=IF(AND(FIND("-",A13&"--",FIND("-",A13&"-")+1)<LEN(A13)-3,OR(MID(TRIM(A13),LEN(TRIM(A13))-4,2)={"-L","-R","-S"})),LEFT(RIGHT(TRIM(A13),4)),"")
 
Last edited:
Upvote 0
I forgot about the HTML translator... here is the full formula...


=IF(AND(FIND("-",A13&"--",FIND("-",A13&"-")+1)<LEN(A13)-3,OR(MID(TRIM(A13),LEN(TRIM(A13))-4,2)={"-L","-R","-S"})),LEFT(RIGHT(TRIM(A13),4)),"")
As far as the evidence is so far, we are no longer dealing with the OP's data as
- there was no sample data with more than 2 dashes, &
- post 5

However
IF your interpretation was correct then this shorter formula seems to produce the result requested and does not return an incorrect "" for
BW1550T-NAV-L  D

& does not return an incorrect "L" for
BW1550T-NAV-L         4D

=IF(AND(LEN(REPLACE(A2,1,FIND("-",A2&"--",FIND("-",A2&"-")+1),""))=4,OR(LEFT(RIGHT(A2,4))={"L","R","S"})),LEFT(RIGHT(A2,4)),"")
 
Upvote 0

Forum statistics

Threads
1,215,084
Messages
6,123,024
Members
449,092
Latest member
ikke

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