ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   If formula (https://www.excelbanter.com/excel-worksheet-functions/233272-if-formula.html)

Cassius

If formula
 
I have cells where I am trying to eliminate text after the dash, but it gives
me errors if the cells does not contain a dash. How can I have it just give
me what is in the cell if no dash is found?

For example (the first one gives it to me correctly, but the second one
finds an error)
NL RISON KANTOOR ITEMS-SCHAGEN NL RISON KANTOOR ITEMS
NL PEJO ELECTROSERVICE B V #VALUE!

My formula reads
=TRIM(LEFT(B2,FIND("-",B2)-1))


Don Guillett

If formula
 
=IF(ISERR(FIND("-",B2)),B2,LEFT(B2,FIND("-",B2)-1))

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Cassius" wrote in message
...
I have cells where I am trying to eliminate text after the dash, but it
gives
me errors if the cells does not contain a dash. How can I have it just
give
me what is in the cell if no dash is found?

For example (the first one gives it to me correctly, but the second one
finds an error)
NL RISON KANTOOR ITEMS-SCHAGEN NL RISON KANTOOR ITEMS
NL PEJO ELECTROSERVICE B V #VALUE!

My formula reads
=TRIM(LEFT(B2,FIND("-",B2)-1))



T. Valko

If formula
 
Try this:

=LEFT(B2,FIND("-",B2&"-")-1)

--
Biff
Microsoft Excel MVP


"Cassius" wrote in message
...
I have cells where I am trying to eliminate text after the dash, but it
gives
me errors if the cells does not contain a dash. How can I have it just
give
me what is in the cell if no dash is found?

For example (the first one gives it to me correctly, but the second one
finds an error)
NL RISON KANTOOR ITEMS-SCHAGEN NL RISON KANTOOR ITEMS
NL PEJO ELECTROSERVICE B V #VALUE!

My formula reads
=TRIM(LEFT(B2,FIND("-",B2)-1))




Dave

If formula
 
Hi Biff,
Jumping in.
Very cool!
Regards - Dave.

"T. Valko" wrote:

Try this:

=LEFT(B2,FIND("-",B2&"-")-1)

--
Biff
Microsoft Excel MVP



Don Guillett

If formula
 
Agreed


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dave" wrote in message
...
Hi Biff,
Jumping in.
Very cool!
Regards - Dave.

"T. Valko" wrote:

Try this:

=LEFT(B2,FIND("-",B2&"-")-1)

--
Biff
Microsoft Excel MVP




T. Valko

If formula
 
Thanks!

--
Biff
Microsoft Excel MVP


"Don Guillett" wrote in message
...
Agreed


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dave" wrote in message
...
Hi Biff,
Jumping in.
Very cool!
Regards - Dave.

"T. Valko" wrote:

Try this:

=LEFT(B2,FIND("-",B2&"-")-1)

--
Biff
Microsoft Excel MVP







All times are GMT +1. The time now is 09:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com