Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
subtracting ranges?
Hi all
I would like to subtract one range from another, i.e. the opposite of rng3 = Union(rng1, rng2). Is this possible? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
subtracting ranges?
Function AntiRange(rngInner As Range, rngOuter As Range) As Range
Dim c As Range If InRange(rngInner, rngOuter) Then For Each c In rngOuter.Cells If Intersect(rngInner, c) Is Nothing Then If AntiRange Is Nothing Then Set AntiRange = c Else Set AntiRange = Union(c, AntiRange) End If End If Next End If MsgBox AntiRange.Address End Function Function InRange(rngInner As Range, rngOuter As Range) As Boolean 'From John Walkenbach If rngInner.Parent.Parent.Name = rngOuter.Parent.Parent.Name Then If rngInner.Parent.Name = rngOuter.Parent.Name Then If Union(rngInner, rngOuter).Address = rngOuter.Address Then InRange = True End If End If End If End Function Note that the inner range has to be completely within the outer range; otherwise some modification will be necessary. -- Vasant "Claude" wrote in message ... Hi all I would like to subtract one range from another, i.e. the opposite of rng3 = Union(rng1, rng2). Is this possible? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
subtracting ranges | Excel Worksheet Functions | |||
how copy formula that contains ranges so ranges do not overlap | Excel Worksheet Functions | |||
Subtracting | Excel Discussion (Misc queries) | |||
Subtracting | Charts and Charting in Excel | |||
Subtracting | Excel Discussion (Misc queries) |