VBA code to ascertain difference between Range1 and Range2
If I understand your question correctly, you want to select the cells in the
Union of Range1 and Range2 that lie outside of their Intersection. If that
is correct, something this should work for you...
' Calculate the union of the two ranges
' with their intersection omitted
Sub SelectDifference(R1 As Range, R2 As Range)
Dim I As Range, C As Range
Dim Difference As Range
Set I = Intersect(R1, R2)
For Each C In Union(R1, R2)
If Intersect(C, I) Is Nothing Then
If Difference Is Nothing Then
Set Difference = C
Else
Set Difference = Union(C, Difference)
End If
End If
Next
Difference.Select
End Function
--
Rick (MVP - Excel)
wrote in message
...
2003, 2007
Would like to be able to ClearContents in the cells representing the
difference between Range1 and
Range2.
If possible like:
Range3 = Union(Range2 - Range1)
Range3.ClearContents
I cannot find a function to accomplish the task. What am I not
considering?
TIA EagleOne
|