Hi All,
Here is a method to extract the range difference.
Code:
Option Explicit
Function RangeDifference(ByRef ActualRange As Range, MinusRange As Range) As Range
'// Author : Krishnakumar
'// Created on : 08-Feb-2012
Dim rngTemp As Range
Dim wksOriginal As Worksheet
Dim wksTemp As Worksheet
Dim lngSU As Long
With Application
lngSU = .ScreenUpdating
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
End With
Set wksOriginal = ActualRange.Parent
Set wksTemp = Worksheets.Add
Set rngTemp = wksTemp.Range(ActualRange.Address)
rngTemp.Value = "z"
wksTemp.Range(MinusRange.Address).Clear
On Error Resume Next
Set RangeDifference = wksOriginal.Range(rngTemp.SpecialCells(xlConstants).Address)
wksTemp.Delete
With Application
.ScreenUpdating = lngSU
.EnableEvents = True
.DisplayAlerts = True
End With
End Function
Bookmarks