URGENT!!! remove everything after a second dash in a string (and the second dash)

Jeffrey Green

Well-known Member
Joined
Oct 24, 2007
Messages
1,021
I have this
[TABLE="width: 174"]
<colgroup><col></colgroup><tbody>[TR]
[TD]1174958190-B33TB-DAA[/TD]
[/TR]
[TR]
[TD]1174988827-B33TB-RTR[/TD]
[/TR]
[TR]
[TD]1175002840-B33TB-[/TD]
[/TR]
[TR]
[TD]AC042130-AECNA-AP[/TD]
[/TR]
[TR]
[TD]1175054679-B33TB-

I only want the data BEFORE the second dash[TABLE="width: 174"]
<colgroup><col></colgroup><tbody>[TR]
[TD]1174958190-B33TB[/TD]
[/TR]
[TR]
[TD]1174988827-B33TB[/TD]
[/TR]
[TR]
[TD]1175002840-B33TB[/TD]
[/TR]
[TR]
[TD]AC042130-AECNA[/TD]
[/TR]
[TR]
[TD]1175054679-B33TB[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 

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:
Excel Workbook
ABC
11174958190-B33TB-DAA1174958190-B33TB
21174988827-B33TB-RTR1174988827-B33TB
31175002840-B33TB-1175002840-B33TB
4AC042130-AECNA-APAC042130-AECNA
51175054679-B33TB-1175054679-B33TB
Sheet
 
Upvote 0
Hi,

Another way:


Book1
AB
11174958190-B33TB-DAA1174958190-B33TB
21174988827-B33TB-RTR1174988827-B33TB
31175002840-B33TB-1175002840-B33TB
4AC042130-AECNA-APAC042130-AECNA
51175054679-B33TB-1175054679-B33TB
Sheet91
Cell Formulas
RangeFormula
B1=REPLACE(A1,FIND("#",SUBSTITUTE(A1,"-","#",2)),255,"")
 
Upvote 0
Jeffrey Green,

If the following is in cell A1:
1174958190-B33TB-DAA

In cell B1 enter the following formula:
=LEFT(A1,FIND("@",SUBSTITUTE(A1,"-","@",(LEN(A1)-LEN(SUBSTITUTE(A1,"-","")))/LEN("-")))-1)

Cell B1 will display:
1174958190-B33TB

And, then copy cell B1 down to the last used row in column A
 
Upvote 0
You're welcome, glad to contribute.

AhoyNC's formula in Post #2 can also be shortened to this:

=LEFT(A1,FIND("#",SUBSTITUTE(A1,"-","#",2))-1)
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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