I am extracting all text before a comma and am using this formula:
=LEFT(F2,(FIND(",",F2,1)-1))
Some cells do not contain commas, and for these I am getting a #VALUE error.
I would like the original text to show up in the error cells, and have been trying to incorporate IFERROR
/ISERROR
or IF
functions- but now sure how to add to existing formula so that the original text will show up.
Example:
Red Barn, 20
(my formula correctly shows “Red Barn
“)
Red Bard
(my formula shows #VALUE
– when I would like “Red Barn” to be shown)
Thanks!
You get this error because FIND
cannot find the required character in the text F2. You can use an IFERROR()
around this FIND()-1
:
=LEFT(F2,IFERROR(FIND(",",F2,1)-1,LEN(F2)))
If there’s no ,
, then it will make LEN(F2)
will will result in the whole text.
Also, you can omit the last 1
in FIND
since that’s the default value.
=LEFT(F2,IFERROR(FIND(",",F2)-1,LEN(F2)))
Tags: excelexcel, function