Returns True if rng1 is a subset of rng2 : Range Union « Excel « VBA / Excel / Access / Word






Returns True if rng1 is a subset of rng2

 
Function InRange(rng1, rng2) As Boolean
    InRange = False
    If rng1.Parent.Parent.Name = rng2.Parent.Parent.Name Then
        If rng1.Parent.Name = rng2.Parent.Name Then
            If Union(rng1, rng2).Address = rng2.Address Then
                InRange = True
            End If
        End If
    End If
End Function

 








Related examples in the same category

1.Using the Union Method to Join Multiple Ranges
2.Use Union when you want to generate a range from two or more blocks of cells.
3.Determining whether a range is contained in another range