Msgbox if cell is not a value

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
 
B

Bob Phillips

A particular value?

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

MsgBx "error"

or any value?

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

MsgBx "error"
 
K

KP

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
 
B

Bob Phillips

How about

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

MsgBox "error"
End If
 

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

Top