Extract a part of a string of data

datadummy

Active Member
Joined
Mar 16, 2017
Messages
312
Office Version
  1. 365
Platform
  1. Windows
I am wondering is it possible to write a formula that can extract a specific part of a string of data?
Example string:
ACETAMINOPHEN 300 MG-CODEINE 30 MG TABLET
For this one I would want to single out the 30 not necessarily concerned with the MG.

<colgroup><col width="493" style="width: 370pt; mso-width-source: userset; mso-width-alt: 17521;"> <tbody> </tbody>
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
lots of conditions might need to be met for this to work since there are 2 numbers in string

1. Will it ALWAYS be after the "-" hyphen
2. Will there ALWAYS be an "MG" after the number you need
3. Is there ALWAYS another number prior to reaching the desired number
 
Upvote 0
This works on your sample, but may not work for other values.
=MID(SUBSTITUTE(G2," ",REPT(" ",200)),SEARCH(" MG ",SUBSTITUTE(G2," ",REPT(" ",200)))-300,200)*1
 
Upvote 0

Forum statistics

Threads
1,215,676
Messages
6,126,168
Members
449,296
Latest member
tinneytwin

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