Hi serdar,
Intersect() is a VBA function which returns a range which is the
intersection between the ranges used as arguments in this functions. If the
ranges evaluated do not intersect then Intersect() returns Nothing.
In the specific example Target is the variable for the range being modified
(which triggers the Change event of the Worksheet). It can be one or
multiple cells. Normally, you modify one cell at a time so Target would
return a one cell range in most of the cases, however it will return a
multi-cell range if you copy-paste multiple cells, etc.
Me is the short way of referring to the object in whose VBA module the macro
is. In this particular case Me refers to the worksheet which we are
monitoring for changes.
[A1] is the range that we actually monitor as we don't care about the rest
of the cells on this sheet.
So Intersect(Target, Me.[a1]) is trying to determine the range which is the
intersection of the range being changed and the range we are monitoring.
This will be the case if A1 is one of the cells changed. If A1 is not being
changed in this particular event, Intersect(Target, Me.[a1]) will return
Nothing, which is what we are trying to trap with the If...Then construct.
The Not operator changes boolean result (TRUE/FALSE) to its opposite, so the
statement "Not Intersect(Target, Me.[a1]) Is Nothing" actually means:
Intersect(Target, Me.[a1]) Is NOT Nothing
Therefore the statement "If Not Intersect(Target, Me.[a1]) Is Nothing Then
..." means: if the intersection between the 'range changed' and A1 is not
nothing (is a range), then proceed with the following action (otherwise do
nothing).
Hope this helps,
Regards,
KL
serdar said:
i am unfamiliar with vbasic syntax..so what is
Intersect( )
and
Is Nothing?
--If Not Intersect(Target, Me.[a1]) Is Nothing