'Trim'....I think!

EvansB2

Board Regular
Joined
Nov 25, 2008
Messages
245
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I'm having trouble trying to split out specific text in a longer text string. So, in the example below, Column B requires a formula to state either East, North, South or West, depending on what is entered in column A (as highlighted in red). I have a long list of data in column A and it is all uniform as can be seen that the text string starts with the same length of characters every time and so should make it possible to have the one formula.

Any assistance would be gratefully received as the data set is large!

Regards
Ben

AB
1LocationBlock Name
2RainH TC | East B | 00 | 3005 | English ClassroomEast
3RainH TC | North B | 00 | 1062 | Mat StoreNorth
4RainH TC | South B | 00 | 1001g | CorridorSouth
5RainH TC | West B | 00 | 1029 | SenCoWest
6
7
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
try this

Book1
AB
1LocationBlock Name
2RainH TC | East B | 00 | 3005 | English ClassroomEast
3RainH TC | North B | 00 | 1062 | Mat StoreNorth
4RainH TC | South B | 00 | 1001g | CorridorSouth
5RainH TC | West B | 00 | 1029 | SenCoWest
Sheet3
Cell Formulas
RangeFormula
B2:B5B2=LOOKUP(2,1/ISNUMBER(SEARCH({"East","South","North","West"},A2)),{"East","South","North","West"})
 
Upvote 0
Hi, here's another option you can also try.

Book1
AB
1LocationBlock Name
2RainH TC | East B | 00 | 3005 | English ClassroomEast
3RainH TC | North B | 00 | 1062 | Mat StoreNorth
4RainH TC | South B | 00 | 1001g | CorridorSouth
5RainH TC | West B | 00 | 1029 | SenCoWest
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=TRIM(LEFT(SUBSTITUTE(MID(A2,FIND("|",A2)+2,255)," ",REPT(" ",255)),255))
 
Upvote 0
Thank you very much both of you. Have successfully tested both approaches.

I'll stick with the 'TRIM' as it will be more robust when potential spelling anomalies creep in over time!

Ben
 
Upvote 0
Thank you very much both of you. Have successfully tested both approaches.

I'll stick with the 'TRIM' as it will be more robust when potential spelling anomalies creep in over time!

Ben
you're welcome
glad that work out for you
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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