Extracting a character string from the Midde

CatsIgnoreMe

New Member
Joined
Feb 8, 2016
Messages
15
Hi,
I've reviewed previous forum posts and attempted to figure out how to do this. No luck. I'm looking for a formula(s) that can extract the a. choice, the b. choice, the c. choice, and the d. choice (see example below).

It does not need to be an all encompassing formula (if that's easier for you) containing all 4 choices. I'm happy with a formula that I can use with extracting the a. choice, and then modifying it to extract the b. choice, etc.. I'm using Excel 2016.
Code:
[TABLE="width: 503"]
<tbody>[TR]
  [TD="class: xl63, width: 503"][INDENT]Which value rolls up to the  Master in forecasting? Choose 1.  a.  Expected revenue  b. Quota Amount  c. Opportunity amount  d. Product Quantity[/INDENT]
[/TD]
[/TR]
</tbody>[/TABLE]
[code]

Thank you for your help. It's much appreciated!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try you will need to change the a. to the choice you are extracting and b. to the next choice.
Code:
=TRIM(MID(A2,SEARCH("a.",A2),SEARCH("b.",A2)-SEARCH("a.",A2)))

for the last choice just put a big number in so that it pulls the whole choice
Code:
=TRIM(MID(A2,SEARCH("d.",A2),9999999))
 
Upvote 0
Assuming your entry is in A1, here are formulas you can use:
Choice a: =MID(A1,FIND(" a. ",A1)+4,FIND(" b. ",A1)-FIND(" a. ",A1)-4)
Choice b: =MID(A1,FIND(" b. ",A1)+4,FIND(" c. ",A1)-FIND(" b. ",A1)-4)
Choice c: =MID(A1,FIND(" c. ",A1)+4,FIND(" d. ",A1)-FIND(" c. ",A1)-4)
Choice d: =MID(A1,F IND(" d. ",A1)+4,LEN(A1))
 
Upvote 0
similarly


Excel 2012
ABCDE
1a.b.c.d.
2Which value rolls up to the Master in forecasting? Choose 1. a. Expected revenue b. Quota Amount c. Opportunity amount d. Product QuantityExpected revenueQuota AmountOpportunity amountProduct Quantity
Sheet4
Cell Formulas
RangeFormula
B2=TRIM(IF(C1="",TRIM(RIGHT($A2,LEN($A2)-FIND(B$1,$A2)-1)),MID($A2,FIND(B$1,$A2)+2,FIND(C$1,$A2)-FIND(B$1,$A2)-2)))
 
Last edited:
Upvote 0
Try you will need to change the a. to the choice you are extracting and b. to the next choice.
Code:
=TRIM(MID(A2,SEARCH("a.",A2),SEARCH("b.",A2)-SEARCH("a.",A2)))

for the last choice just put a big number in so that it pulls the whole choice
Code:
=TRIM(MID(A2,SEARCH("d.",A2),9999999))

Fantastic! Worked beautifully. I have new appreciation for the TRIM function.
 
Upvote 0
Assuming your entry is in A1, here are formulas you can use:
Choice a: =MID(A1,FIND(" a. ",A1)+4,FIND(" b. ",A1)-FIND(" a. ",A1)-4)
Choice b: =MID(A1,FIND(" b. ",A1)+4,FIND(" c. ",A1)-FIND(" b. ",A1)-4)
Choice c: =MID(A1,FIND(" c. ",A1)+4,FIND(" d. ",A1)-FIND(" c. ",A1)-4)
Choice d: =MID(A1,F IND(" d. ",A1)+4,LEN(A1))

This worked well also. I did want to keep the "a." as part of the character string so I modified your formula removing the +4 and -4 and replacing with +1 and -1
Code:
Choice a: =MID(A1,FIND(" a. ",A1)+1,FIND(" b. ",A1)-FIND(" a. ",A1)-1)

Thank you for responding so quickly. I look forward to carefully parsing the formulas offered to improve my Excel skills.
 
Last edited:
Upvote 0
similarly

Excel 2012
ABCDE
1a.b.c.d.
2Which value rolls up to the Master in forecasting? Choose 1. a. Expected revenue b. Quota Amount c. Opportunity amount d. Product QuantityExpected revenueQuota AmountOpportunity amountProduct Quantity

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet4

Worksheet Formulas
CellFormula
B2=TRIM(IF(C1="",TRIM(RIGHT($A2,LEN($A2)-FIND(B$1,$A2)-1)),MID($A2,FIND(B$1,$A2)+2,FIND(C$1,$A2)-FIND(B$1,$A2)-2)))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Interesting approach I'll remember for future reference. I'm sure I'll need this at some point!
 
Upvote 0
This worked well also. I did want to keep the "a." as part of the character string so I modified your formula removing the +4 and -4 and replacing with +1 and -1
I wasn't quite clear on that, but am glad to see you were able to figure out how the formula works and were able to adjust it.

BTW, like the user name. Don't feel too bad. Cats ignore pretty much everybody!:ROFLMAO:
 
Upvote 0
I wasn't quite clear on that, but am glad to see you were able to figure out how the formula works and were able to adjust it.

BTW, like the user name. Don't feel too bad. Cats ignore pretty much everybody!:ROFLMAO:

After spending 3 hours trying to figure this out, I appreciate the quick and multiple useful responses. Thank you to everyone. And yeah, somehow I stumbled into a short and memorable user name. Generally I'm not that creative. :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

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