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:
Hi Rick,

thank you for your reply. I like the single formula solution!
 
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Extract text

ABC
T4290 Benareby (Härryda kommun)BenarebyHärryda

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:230px;"><col style="width:74px;"><col style="width:83px;"></colgroup><tbody>
[TD="bgcolor: #cacaca, align: center"]1[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
B1=TRIM(REPLACE(LEFT(A1,FIND("(",A1)-1),1,5,""))

<tbody>
</tbody>

<tbody>
</tbody>
For your B1 formula, why not this instead...

=MID(LEFT(A1,FIND("(",A1)-1),7,99)
 
Upvote 0
For your B1 formula, why not this instead...

=MID(LEFT(A1,FIND("(",A1)-1),7,99)
Only that the OP said they wanted to remove the first 5 characters, so I took that literally. (Though not some other parts see below. :))

BTW, your suggestion would need to be -2 or perhaps safer include TRIM() or else a space is likely left on the end.



I like the single formula solution!
Just be aware that different formulas suggested in the thread may bring different results.
Having re-read your question and considered your possible data, I'm not sure any of the suggestions, including mine, would be sure to bring you your desired results. I'm proposing this instead. I am assuming that spaces after the Småortskod (hope that is correct :)), before the "(" and "kommun" are uniform.

Excel Workbook
ABC
1T4290 Benareby (Hrryda kommun)BenarebyHrryda
2S5133 Lekvall (Lilla Edet kommun)LekvallLilla Edet
3S4474 Stora Brta (Hrryda kommun)Stora BrtaHrryda
Extract text
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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