Formula to Extract Numbers from String

JamesA11

New Member
Joined
Oct 2, 2020
Messages
18
Office Version
  1. 2019
Platform
  1. Windows
Hi,

I have a cell that contains strings such as the example below:

['12-3', '11-6', '3-1']

Each of the values in apostrophes is a reference. Sometimes the will be a single reference (eg ['111-2']), sometimes two and sometimes three. Each reference is always encased within apostrophes.

Is it possible to extract the references with formulae to give the following result (using the above example)? ie each reference in a separate cell and the apostrophes, etc removed.

12-3
11-6
3-1

Thanks
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Let's say that your entry is in cell A1.

Then here are three formula that will work:

First entry:
Excel Formula:
=TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"[",""),"]",""),"'",""),",",REPT(" ",100)),1,100))

Second entry:
Excel Formula:
=TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"[",""),"]",""),"'",""),",",REPT(" ",100)),101,100))

Third entry:
Excel Formula:
=TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"[",""),"]",""),"'",""),",",REPT(" ",100)),201,100))
 
Upvote 0
Solution
Wow Joe, that's incredible! No wonder I couldn't do it. Thank you very much.
 
Upvote 0
Wow Joe, that's incredible! No wonder I couldn't do it. Thank you very much.
You are welcome.
That is just one way. There are other (maybe shorter) ways.

Though the formula is long, it really isn't too complicated. We are using three of those "Substitute" functions to remove the unwanted characters of [, ], and '.
And then we are replacing the commas with 100 spaces.
Then we are just taking the first 100 characters for the first one, and trimming off all the extra spaces.
Then taking the next 100 characters for the second one, and trimming off all the extra spaces.
etc.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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