it
If Target = Range("D4") Then
equivalent to this
If Target.Value = Range("D4").Value Then
which is clearly not what you want. You will probably get an error if Target.Value
not of the same type as Range("D4").Value
.
What you want is:
If Not Intersect(Target, Range("D4")) Is Nothing Then
EDIT I just managed to reproduce your error. This happens if the Target
range has a different size than Range("D4")
, that is, it spans more than one cell. As @Dick Kusleiska notes, this also happens if one of the two is an error value. Perhaps this is caused by other things, I do not know. In any case, the fact is that your If
condition is incorrect!
source share