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

Jeffrey Green

Well-known Member
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>
 

AhoyNC

Well-known Member
Try:
Excel Workbook
ABC
11174958190-B33TB-DAA
21174988827-B33TB-RTR1174988827-B33TB
31175002840-B33TB-1175002840-B33TB
4AC042130-AECNA-APAC042130-AECNA
51175054679-B33TB-1175054679-B33TB
Sheet
 

jtakw

Well-known Member
Hi,

Another way:

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style=";">1174958190-B33TB-DAA</td><td style=";">1174958190-B33TB</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">1174988827-B33TB-RTR</td><td style=";">1174988827-B33TB</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">1175002840-B33TB-</td><td style=";">1175002840-B33TB</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style=";">AC042130-AECNA-AP</td><td style=";">AC042130-AECNA</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style=";">1175054679-B33TB-</td><td style=";">1175054679-B33TB</td></tr></tbody></table><p style="width:5.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet91</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">B1</th><td style="text-align:left">=REPLACE(<font color="Blue">A1,FIND(<font color="Red">"#",SUBSTITUTE(<font color="Green">A1,"-","#",2</font>)</font>),255,""</font>)</td></tr></tbody></table></td></tr></table><br />
 

hiker95

Well-known Member
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
 

jtakw

Well-known Member
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)
 

Some videos you may like

This Week's Hot Topics

Top