ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Trapping #VALUE! error (https://www.excelbanter.com/excel-discussion-misc-queries/155211-trapping-value-error.html)

RhysPieces

Trapping #VALUE! error
 
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.


Peo Sjoblom

Trapping #VALUE! error
 
=IF(ISNUMBER(FIND("/",A1)),--MID(A1,1,FIND("/",A1)-1),A1)


--
Regards,

Peo Sjoblom




"RhysPieces" wrote in message
...
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.




Elisabeth

Trapping #VALUE! error
 
=IF(ISERROR(MID(A1,1,FIND("/",A1)-1)),"")
--
Elisabeth


"RhysPieces" wrote:

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. Valko

Trapping #VALUE! error
 
Here's one way:

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

Or:

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

--
Biff
Microsoft Excel MVP


"RhysPieces" wrote in message
...
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.




Elisabeth

Trapping #VALUE! error
 
Disregard my answer--it won't work--sorry.
--
Elisabeth


"Elisabeth" wrote:

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


"RhysPieces" wrote:

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.


RhysPieces

Trapping #VALUE! error
 
The solutions from T. Valko and Peo Sjoblom work equally well. Thanks to both
for prompt replies.

"T. Valko" wrote:

Here's one way:

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

Or:

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

--
Biff
Microsoft Excel MVP


"RhysPieces" wrote in message
...
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. Valko

Trapping #VALUE! error
 
You're welcome. Thanks for the feedback!

--
Biff
Microsoft Excel MVP


"RhysPieces" wrote in message
...
The solutions from T. Valko and Peo Sjoblom work equally well. Thanks to
both
for prompt replies.

"T. Valko" wrote:

Here's one way:

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

Or:

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

--
Biff
Microsoft Excel MVP


"RhysPieces" wrote in message
...
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.








All times are GMT +1. The time now is 04:45 AM.

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