check for "#VALUE!"

F

fabalicious

Hi there.

I want to check if a cell's value is "#VALUE!". How can I do this?

If Cells(1, 1).Value = "#VALUE!" Then
...

... doesnt work.

Thanks
 
B

Bob Flanagan

You can do it this way:

If ActiveCell.Value = CVErr(xlErrValue) Then
MsgBox "value error"
End If

more general is:

If IsError(ActiveCell.Value) Then
MsgBox "the cell contains an error value"
End If

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
T

tinyjack

You can use a combination of IsError and CVErr, something like:


Code
-------------------

If IsError(Cells(1, 1).Value) Then

If Cells(1,1).Value = CVErr(xlErrValue) Then

MsgBox "#Value Error in Cell"

Else

MsgBox "Other Error in Cell"

End If

Else

MsgBox "No Error in Cell"

End If

-------------------


Check the help files for more information.

T
 
Top