Thread: VBA question
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default VBA question

Use Cells.Text rather than Cells.Value:

Sub test()
If ActiveCell.Text = "#VALUE!" Then
MsgBox ("found it")
End If
End Sub

--
Gary''s Student - gsnu200764


"jayahn" wrote:

Why is the macro unable to identify #VALUE! as a string?

I have a macro which inputs functions in to the cells, then cuts and pastes
by values (so that the function results are static). After that I wish to
delete all rows with cells that have #VALUE! (as a string itself) in it, but
it cannot seem to identify it. Below is a test macro to demonstrate. The Cell
A1 should have #VALUE! in it.

Sub test()
If IsEmpty(Cells(1, 1)) Then
MsgBox ("A1 empty")
Else
MsgBox ("A1 not empty")
MsgBox Cells(1, 1).Value
End If
End Sub

Is there any other way I can check whether a cell is containing #VALUE! as a
string?
Thank you.

- Jay -