Character removal

Deelof

New Member
Joined
Aug 30, 2023
Messages
46
Office Version
  1. 2019
Platform
  1. Windows
What's the best formula to use if I want to remove "-OLS / -BCLCIRCS / -C" from the end of the below codes?
Leaving BS00008-3 / CF00021-2 / BF00027-9

BS00008-3-OLS
CF00021-2-BCLCIRCS
BF00027-9-C
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
If there are only 2 hyphens in all your data you could e.g. try:

Excel Formula:
=LEFT(A1,SEARCH("|",SUBSTITUTE(A1,"-","|",2))-1)
 
Upvote 0
If your sample data is representative then you could just use this.

24 07 29.xlsm
AB
1BS00008-3-OLSBS00008-3
2CF00021-2-BCLCIRCSCF00021-2
3BF00027-9-CBF00027-9
Deelof
Cell Formulas
RangeFormula
B1:B3B1=LEFT(A1,9)
 
Upvote 0
Oh, thanks. My mistake.
Here the corrected formula for excel 2019:

Book5.xlsx
AB
1BS00-OLS008-3-OLSBS00-OLS008-3
2CF0002-BCLCIRCS1-2-BCLCIRCSCF0002-BCLCIRCS1-2
3BF00-BCLCIRCS-027-9-CBF00-BCLCIRCS-027-9
Sheet7
Cell Formulas
RangeFormula
B1:B3B1=CONCAT(IF(RIGHT(A1,LEN({"-OLS";"-BCLCIRCS";"-C"}))={"-OLS";"-BCLCIRCS";"-C"},LEFT(A1,LEN(A1)-LEN({"-OLS";"-BCLCIRCS";"-C"})),""))
 
Upvote 0

Forum statistics

Threads
1,221,531
Messages
6,160,366
Members
451,642
Latest member
mirofa

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