跳到主要内容

Intersect

Returns the ApiRange object that represents the rectangular intersection of two or more ranges. If one or more ranges from a different worksheet are specified, an error will be returned.

Syntax

expression.Intersect(Range1, Range2);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
Range1RequiredApiRangeOne of the intersecting ranges. At least two Range objects must be specified.
Range2RequiredApiRangeOne of the intersecting ranges. At least two Range objects must be specified.

Returns

ApiRange | null

Example

This example shows how to get the ApiRange object that represents the rectangular intersection of two or more ranges.

var oWorksheet = Api.GetActiveSheet();
var oRange1 = oWorksheet.GetRange("A1:C5");
var oRange2 = oWorksheet.GetRange("B2:B4");
var oRange = Api.Intersect(oRange1, oRange2);
oRange.SetFillColor(Api.CreateColorFromRGB(255, 213, 191));