Trapping #VALUE! error

G

Guest

I am using a MID function to extract numbers from a string:
=--MID(A1,1,FIND("/",A1)-1)
If the string does not contain "/", it results in the #VALUE! error.
What code needs to go in front of the formula to trap this and return ""?

Thank you for your replies.
 
T

T. Valko

Here's one way:

=IF(ISERR(FIND("/",A1)),"",--MID(A1,1,FIND("/",A1)-1))

Or:

=IF(ISERR(FIND("/",A1)),"",--LEFT(A1,FIND("/",A1)-1))
 
G

Guest

The solutions from T. Valko and Peo Sjoblom work equally well. Thanks to both
for prompt replies.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top