I have this cell.Offset(0, -2)
cell that I need to check if it exists inside my VBA loop.
My idea is that if the cell
has an .Offset(0, -2)
that does not exist (e.g. say cell
= Column B and cell.Offset(0, -2)
= Column A-1, cell.Offset(0, -2)
is supposed to be invalid), I want to be able to check that it doesn't exist in the if else statement.
Right now when it doesn't exist, I'm getting a “Runtime Error 1004: Application defined or object defined error”
.
I've tried IsErr(cell.Offset(0, -2))
, cell.Offset(0, -2).Value
, If cell.Offset(0, -2) Is Nothing Then
, cell.Offset(0, -2) = ""
, but none of them seem to work... can anyone point me in the right direction? I'm pretty new to VBA and it seems like different variable types have different ways of checking if the value exists.
If cell.column > 2 then...
– Darrell HIf Not Intersect(cell, [range which is ok]) Is Nothing Then
... – Dirk Reichel