RectIntersect Method

Microsoft Office Web Components Visual Basic

expression.RectIntersect(Range1, Range2)

expression    Required. An expression that returns a Spreadsheet object

Range1   Required Range.

Range2   Required Range.

Example

This example bolds the cells where the named range "Range1" overlaps the named range "Range2" in the active sheet of Spreadsheet1.

Sub BoldIntersection()

    Dim rngIntersect
    Dim rngFirstRange
    Dim rngSecondRange

    ' Set a variable to the first named range.
    Set rngFirstRange = Spreadsheet1.ActiveSheet.Range("Range1")

    ' Set a variable to the second named range.
    Set rngSecondRange = Spreadsheet1.ActiveSheet.Range("Range2")

    ' Set a variable to the intersection of the two named ranges.
    Set rngIntersect = Spreadsheet1.RectIntersect(rngFirstRange, rngSecondRange)

    ' Check whether the named ranges overlap.
    If Not rngIntersect Is Nothing Then

        ' Bold the font in the overlapping portion
        ' of the two ranges.
        rngIntersect.Font.Bold = True

    End If

End Sub