Stripping numbers from a cell

Bennets04

Board Regular
Joined
Jul 30, 2010
Messages
65
Hi All,
What would be the best formula to use to get the data from the below.... Im looking at just grabbing data in the [ ]'s from over 5,000 lines of data

Roshani [ RL52486 ] I'm looking to just get RLr2486
Ozlem [ OK51419 ] I'm looking to get OK51419
Robert [ RConville ] I'm looking to get RConville

Many thanks
Steve
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Here is one way, for an entry in cell A1:
Code:
=TRIM(MID(SUBSTITUTE(SUBSTITUTE(A1,"[",REPT(" ",200)),"]",REPT(" ",200)),200,100))
 
Upvote 0
You are welcome.
The formula does look a little crazy, but actually works on a simple premise.
We are simply replacing the "[" and "]" signs with 200 spaces each.
Then, we are taking the middle 100 characters (so you will have what you want surrounded by a bunch of spaces on each side).
We then just use the TRIM function to get rid of all the beginning and ending spaces.
 
Upvote 0
Hi,

Another way, slightly shorter:


Book1
AB
1Roshani [ RL52486 ]RL52486
2Ozlem [ OK51419 ]OK51419
3Robert [ RConville ]RConville
Sheet205
Cell Formulas
RangeFormula
B1=TRIM(MID(SUBSTITUTE(SUBSTITUTE(A1,"]",""),"[",REPT(" ",255)),255,255))
 
Upvote 0
Here is another somewhat shorter formula...

=TRIM(MID(LEFT(A1,FIND("]",A1)-1),FIND("[",A1)+1,99))
 
Upvote 0
Also:
=TRIM(SUBSTITUTE(MID(A2,FIND("[",A2&"[")+1,99),"]",""))


Excel 2010
AB
2Roshani [ RL52486 ]RL52486
3Ozlem [ OK51419 ]OK51419
4Robert [ RConville ]RConville
5 
Sheet1
Cell Formulas
RangeFormula
B2=TRIM(SUBSTITUTE(MID(A2,FIND("[",A2&"[")+1,99),"]",""))
B3=TRIM(SUBSTITUTE(REPLACE(A3,1,FIND("[",A3&"["),""),"]",""))
B4=TRIM(SUBSTITUTE(REPLACE(A4,1,FIND("[",A4&"["),""),"]",""))
B5=TRIM(SUBSTITUTE(REPLACE(A5,1,FIND("[",A5&"["),""),"]",""))
 
Last edited:
Upvote 0
Good morning,

Thank you for your support yesterday. How about stripping the [ **** ] out completely with a formula?

UK Customer - Store - Bedford [ 891 ]
UK Customer - Store - St Helens [ 978 ]
UK Customer - Store - Covent Garden [ 1338 ]
UK Customer - Store - Covent Garden [ 1338 ]

So when I drag the formula down it will just provide

UK Customer - Store - Bedford
UK Customer - Store - St Helens
UK Customer - Store - Covent Garden

Thank you so much for your support :)
 
Upvote 0
Hi,

Use this:


Book1
AB
1UK Customer - Store - Bedford [ 891 ]UK Customer - Store - Bedford
2UK Customer - Store - St Helens [ 978 ]UK Customer - Store - St Helens
3UK Customer - Store - Covent Garden [ 1338 ]UK Customer - Store - Covent Garden
4UK Customer - Store - Covent Garden [ 1338 ]UK Customer - Store - Covent Garden
5UK Customer - Store - Covent Garden-St Helens[123-456 1338 ]UK Customer - Store - Covent Garden-St Helens
Sheet202
Cell Formulas
RangeFormula
B1=TRIM(REPLACE(A1,FIND("[",A1),255,""))


Formula copied down.
 
Upvote 0

Forum statistics

Threads
1,215,594
Messages
6,125,723
Members
449,255
Latest member
whatdoido

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