Extract A String Between Two Characters

theaudioguy

New Member
Joined
Jan 27, 2010
Messages
27
I'm stuck. I need a formula to extract data from between two characters.

For Example, In A1 I have this: COMP_PROG_v1_ABCD_01

I want to extract the value between the 3rd and 4th "_"'s. The number of "_"'s will be consistent but not the # of characters between them. My brain is tired of thinking. Thanks.
 
How about this
Enter in B1 and copy down
=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",99)),99*(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-1),99))


Book1
AB
1PRIVATE LABEL BRAND SALTED ROASTED REGULAR 40OZ 12698047440OZ
2HAPPY SALTED ROASTED REGULAR 6.25OZ 13447028216.25OZ
3YOYO FARMS SALTED ROASTED HEDGEHOGS 16OZ 458132895416OZ
Sheet1
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi all,

I have gone through each page in this thread and have not been able to find a solution for this:

I want to return the value in-between the parentheses:

<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
Nicky Ring (Grow Learning)
Chloe Fulman (Jeanswest)
Corey Brewer (Uphill)
Charles Post (Skilled People)
David Chow (Easy Dreams)

<colgroup><col style="width: 250px"></colgroup><tbody>
</tbody>

So output would be:
Grow Learning
Jeanswest
Uphill
Skilled People
Easy Dreams

Your help is much appreciated!
 
Upvote 0
Try this
Enter in B1 and copy down

=SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A1,"(",REPT(" ",99)),99)),")","")


Book1
AB
1Nicky Ring (Grow Learning)Grow Learning
2Chloe Fulman (Jeanswest)Jeanswest
3Corey Brewer (Uphill)Uphill
4Charles Post (Skilled People)Skilled People
5David Chow (Easy Dreams)Easy Dreams
Sheet1
 
Upvote 0
Hello all,

I have another problem in the same register as the one above:

I have a columns of text with cell like below:

ABCD-01=1,ABCD-02=10,ABCD-04=10,ABCD-06=10,ABCD-08=1,ABCD-09=1

<colgroup><col width="559"></colgroup><tbody>
</tbody>

I need to extract as follows: on one row the string ABCD-01, ABCD-02, ABCD-03, etc. and on another row the number 1, 10, 10, etc.

Since it's not the same separator ("=" and ","), I am having problems. Any advice from the magicians around here?

Thank you to all!
 
Upvote 0
Hello all,

I have another problem in the same register as the one above:

I have a columns of text with cell like below:

ABCD-01=1,ABCD-02=10,ABCD-04=10,ABCD-06=10,ABCD-08=1,ABCD-09=1

<tbody>
</tbody>

I need to extract as follows: on one row the string ABCD-01, ABCD-02, ABCD-03, etc. and on another row the number 1, 10, 10, etc.

Since it's not the same separator ("=" and ","), I am having problems. Any advice from the magicians around here?

Thank you to all!

I just realized I wasn't so clear:

If the text above is in A1, I need ABCD-01 in B1, ABCD-02 in C1, etc. and 1 in B2, 10 in C2, etc.

Thank you!
 
Upvote 0
Hello all,

I have another problem in the same register as the one above:
Welcome to the MrExcel board!

Are you after something like this?
Each formula copied across.

Excel Workbook
ABCDEFG
1ABCD-01=1,ABCD-02=10,ABCD-04=10,ABCD-06=10,ABCD-08=1,ABCD-09=1ABCD-01ABCD-02ABCD-04ABCD-06ABCD-08ABCD-09
2110101011
Extract Parts
 
Upvote 0
Beaten 2 it, but another option
=TRIM(MID(SUBSTITUTE($A$1,"=",REPT(" ",100)),SEARCH(",",","&SUBSTITUTE($A$1,"=",REPT(" ",100)),COLUMN(A1)*100-99),100))
=TRIM(MID(SUBSTITUTE($A$1,",",REPT(" ",100)),SEARCH("=",SUBSTITUTE($A$1,",",REPT(" ",100)),COLUMN(A2)*100-99)+1,100))
 
Upvote 0
Thank you very much Peter!

For my example above it works, however if the string is larger, it seems to break at some point. I can't seem to figure out why.

For example, for this string:

ABCD-01=1,ABCD-02=1,ABCD-03=10,ABCD-04=10,ABCD-05=10,ABCD-06=10,ABCD-07=10,ABCD-08=10,ABCD-09=10,ABCD-10=10,ABCD-11=10,ABCD-12=10,ABCD-13=10,ABCD-14=10,ABCD-15=10,ABCD-16=10,ABCD-17=10

<colgroup><col width="1394"></colgroup><tbody>
</tbody>

After ABCD-11 the result is not alright. It returns 10, 10, etc.

Thank you again!

<colgroup><col width="61"></colgroup><tbody>
</tbody>
 
Upvote 0
Beaten 2 it, but another option
=TRIM(MID(SUBSTITUTE($A$1,"=",REPT(" ",100)),SEARCH(",",","&SUBSTITUTE($A$1,"=",REPT(" ",100)),COLUMN(A1)*100-99),100))
=TRIM(MID(SUBSTITUTE($A$1,",",REPT(" ",100)),SEARCH("=",SUBSTITUTE($A$1,",",REPT(" ",100)),COLUMN(A2)*100-99)+1,100))

Thank you a lot!

This ones seem to work for any length. If I am not too bold, is there any online resources which could help me to better understand the formula?

Thank you so much again!
 
Upvote 0

Forum statistics

Threads
1,215,011
Messages
6,122,680
Members
449,091
Latest member
peppernaut

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