0

Quick question: I have a cell that can have as value or a number or the string "NN"

I wrote this line of code:

If Not IsNumeric(Cells(c, 64)) Or Cells(c, 64) <> "NN" Then
    errCell.Value = "Wrong Div"
    errCell.Interior.Color = RGB(255, 0, 0)
    GoTo Boucle
 End If

I apply to a cell which is a number But I get an error... Any lead would be great Thank you

5
  • 1
    And you get the error where? And the error msg? Commented Mar 14, 2014 at 16:41
  • I have a the Wrong Div message ... basically the macro compiles well but it should not specify this error since the cell is a number Commented Mar 14, 2014 at 16:43
  • Or >> And should fix it Commented Mar 14, 2014 at 16:46
  • Of course it should, the right side of the OR returs true so it writes "Wrong Div", maybe you want to replace OR by AND Commented Mar 14, 2014 at 16:47
  • was so simple... damn myself... thank you guys Commented Mar 14, 2014 at 16:49

1 Answer 1

1

I think you have a logic error - as it stands the error message is always shown. Try:

If Not IsNumeric(Cells(c, 64)) AND Cells(c, 64) <> "NN"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.