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
1174958190-B33TB-DAA
1174988827-B33TB-RTR
1175002840-B33TB-
AC042130-AECNA-AP
1175054679-B33TB-

I only want the data BEFORE the second dash
1174958190-B33TB
1174988827-B33TB
1175002840-B33TB
AC042130-AECNA
1175054679-B33TB

<colgroup><col></colgroup><tbody>
</tbody>

<colgroup><col></colgroup><tbody>
</tbody>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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
You are a life saver!!!!!!!!!!!!!!!!!!!!!! THANKS SO MUCH, perfect. Not sure how it works, but good for now!
 
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,214,385
Messages
6,119,205
Members
448,874
Latest member
Lancelots

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