Intersect Method

Applies To

Application Object.

Description

Returns the rectangular intersection of two or more ranges.

Syntax

object.Intersect(arg1, arg2, ...)

object

Optional. The Application object.

arg1, arg2, ...

Required. The intersecting ranges. At least two Range objects must be specified.

See Also

Union Method.

Example

This example selects the intersection of two named ranges, rg1 and rg2, on Sheet1. If the ranges do not intersect, the example displays a message.


Worksheets("Sheet1").Activate
Set isect = Application.Intersect(Range("rg1"), Range("rg2"))
If isect Is Nothing Then
    MsgBox "Ranges do not intersect"
Else
    isect.Select
End If