How to remove characters and then split string at a specifc character

Waimea

Active Member
Joined
Jun 30, 2018
Messages
465
Office Version
  1. 365
Platform
  1. Windows
I have a lot of strings that follow the same format.

Code:
[COLOR=#3D3D3D][FONT=arial]T4290 Benareby (Härryda kommun)[/FONT][/COLOR]

Steps:

1.) Remove the first 5 charcters, T4290.
Code:
=RIGHT(A2;LEN(A2)-6)

2.) Remove leading spaces from Benareby. Maybe with TRIM.
Code:
TRIM(B2)

3.) Remove ( kommun) and keep Härryda

I am stuck at step 3 right now?I have tried using REPLACE.

Desired output is
Code:
Column A   Column B
Benareby   Härryda
 
Last edited:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
For an entry in cell A1.

Here is a formula to return the first part:
Code:
=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",100)),100,100))

and here is a formula to return the second part:
Code:
=TRIM(LEFT(SUBSTITUTE(MID(A1,FIND("(",A1)+1,100)," ",REPT(" ",100)),100))
 
Upvote 0
How about

Book1
ABC
2T4290 Benareby (Hrryda kommun)BenarebyHrryda
Sheet4
Cell Formulas
RangeFormula
B2=TRIM(MID(SUBSTITUTE(A2,"(",REPT(" ",100)),FIND(" ",A2),100))
C2=TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",100),3),FIND("(",A2)+1,100))
 
Upvote 0
Hi Joe4 and Fluff,

thank you very much for your replies! Both of your formulas work and I am happy!

Thank you again!

I don't understand the use of REPT(100) ?
 
Upvote 0
That part puts 100 spaces into the string, making it easier to get the part you need.
 
Upvote 0
Hi Fluff,

thank you for explanation, it saved me hours of manually removing the unwanted information. :)
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0
One more... a single formula solution for both parts. Assuming your data starts in cell A1, put this formula in cell B1 and copy it to cell C1, then copy B1:C1 down to the bottom of your data (or past it if you want to provide for addition data later on)...

=TRIM(MID(SUBSTITUTE(SUBSTITUTE($A1,"(","")," ",REPT(" ",100)),COLUMNS($B:B)*100,100))
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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