Deselect or Remove from Range?
Is ther any way to deselect a Range or rememove
a range from another range (without removing the
underlying data, just the range definition).
I tried the following code:
Code:
'Does a set difference on two ranges.
'For example:
' subtractRanges = subtractee - subtractor
'Returns the range of cells that are IN the
'subtractee and NOT in the subtractor.
'Example 2:
'RangeA = "A1:A20"
'RangeB = "A1:A10"
'RangeC = subtractRanges(RangeA, RangeB)
'RangeC contains "A11:A20"
Function subractRanges(subtractee As Range, subtractor As Range) As Range
Dim c As Range
For Each c In subtractee
If Intersect(c, subtractor) Is Nothing Then
If subractRanges Is Nothing Then
Set subractRanges = c
Else
Set subractRanges = Union(subractRanges, c)
End If
End If
Next c
End Function
However the opteration I want to do is this:
Code:
Dim garbage As Range
Set garbage = SubtractRanges.subractRanges(ActiveSheet.Cells, Range(ActiveSheet.PageSetup.PrintArea))
If you do this, the subroutine runs for A LONG TIME as it is trying
to compare every cell in the entire sheet to the print area.
Suggestions?