djl0525

Well-known Member
Joined
Dec 11, 2004
Messages
1,240
I need a formula to extract the characters between the second and third hyphen in the strings below.

SAMPLE DATARESULT
1-2-3-43
11-2-333-4333
1-2222-3-44443
11111111-22222222-33333333-4444444433333333

<tbody>
</tbody>

Any assistance will be greatly appreciated!

DJ
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
you can try Power Query

SAMPLE DATAText Between Delimiters
1-2-3-43
11-2-333-4333
1-2222-3-44443
11111111-22222222-33333333-4444444433333333

Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Between = Table.AddColumn(Source, "Text Between Delimiters", each Text.BetweenDelimiters([SAMPLE DATA], "-", "-", 1, 0), type text),
    ROC = Table.SelectColumns(Between,{"Text Between Delimiters"})
in
    ROC[/SIZE]
 
Upvote 0
Try this...

=TRIM(MID(SUBSTITUTE(A2,"-",REPT(" ",100)),200,100))*1

The *1 is to convert the result to a numeric value.
 
Upvote 0
AlphaFrog, can you translate your formula to English for me, please? I'd like to understand it.

Try this...

=TRIM(MID(SUBSTITUTE(A2,"-",REPT(" ",100)),200,100))*1

The *1 is to convert the result to a numeric value.

DeLisa
 
Upvote 0
AlphaFrog, can you translate your formula to English for me, please? I'd like to understand it.

The gist of the formula is to replace a given delimiter with a large number of spaces using SUBSTITUTE and REPT, then use the MID function to extract text related to the 2nd occurrence and then the TRIM function to get rid of the extra spaces.

This site explains it well...
https://exceljet.net/formula/split-text-with-delimiter
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,580
Members
449,039
Latest member
Arbind kumar

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