I am trying to avoid errors when executing a vba script so I check the content of the cells before I do something with them.
If ((Cells(i, 18).Value > 0) And (Trim(Cells(i, 3).Value) <> "") And (Trim(Cells(i, 4).Value) <> "")) And (Trim(Cells(i, 10).Value) <> "") _
Then ' Do something
It works with empty cells but not with cells the contain
“#NAME?”
How can I validate that?
Take a look at the
ERROR.TYPE()worksheet function. This will return 5 is the error is#NAME.If B1 contains your
#NAMEerror, then the following would return 5: