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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,216,131
Messages
6,129,066
Members
449,485
Latest member
greggy

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