Union Method

Microsoft Excel Visual Basic

Returns the union of two or more ranges.

expression.Union(Arg1, Arg2, ...)

expression    Optional. An expression that returns an Application object.

Arg1, Arg2, ... Required Range. At least two Range objects must be specified.

Example

This example fills the union of two named ranges, Range1 and Range2, with the formula =RAND().

Worksheets("Sheet1").Activate
Set bigRange = Application.Union(Range("Range1"), Range("Range2"))
bigRange.Formula = "=RAND()"