check for "#VALUE!"

  • Thread starter Thread starter fabalicious
  • Start date Start date
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
 
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
 
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
 

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

Back
Top