Msgbox if cell is not a value

  • Thread starter Thread starter KP
  • Start date Start date
K

KP

Hi,

If cell is not a value I want a messagebox.

I have no problems creating the msgbox, but how do I write the macro
checking for a value?

Thanks for any help.

Kaj Pedersen
 
A particular value?

If Range("A2").Value2 <> 17 Then

MsgBx "error"

or any value?

If Range("A2").Value2 <> "" Then

MsgBx "error"
 
Hi Bob,

Your first excamle works perfectly but I'm sorry to say that there seems to
be some trouble with the second one.

I want a msgbox if a text or anything else but a value is typed in cell A2.
If I use the macro below, I get the Msgbox, no matter what I write in A2,
even if I write a value.

If Range("A2").Value2 <> "" Then

MsgBox "error"
End If

Hope you can figure out the problem. I use Excel 2003, danish

Kaj Pedersen
 
How about

If Range("A2").Value2 <> "" And Not IsNumeric(Range("A2").Value2) Then

MsgBox "error"
End If
 
Back
Top