Collapse the table of content
Expand the table of content
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Application.Union Method (Excel)

Returns the union of two or more ranges.

expression .Union(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30)

expression A variable that represents an Application object.

Parameters

Name

Required/Optional

Data Type

Description

Arg1

Required

Range

At least two Range objects must be specified.

Arg2

Required

Range

At least two Range objects must be specified.

Arg3

Optional

Variant

At least two Range objects must be specified.

Arg4

Optional

Variant

At least two Range objects must be specified.

Arg5

Optional

Variant

At least two Range objects must be specified.

Arg6

Optional

Variant

At least two Range objects must be specified.

Arg7

Optional

Variant

At least two Range objects must be specified.

Arg8

Optional

Variant

At least two Range objects must be specified.

Arg9

Optional

Variant

At least two Range objects must be specified.

Arg10

Optional

Variant

At least two Range objects must be specified.

Arg11

Optional

Variant

At least two Range objects must be specified.

Arg12

Optional

Variant

At least two Range objects must be specified.

Arg13

Optional

Variant

At least two Range objects must be specified.

Arg14

Optional

Variant

At least two Range objects must be specified.

Arg15

Optional

Variant

At least two Range objects must be specified.

Arg16

Optional

Variant

At least two Range objects must be specified.

Arg17

Optional

Variant

At least two Range objects must be specified.

Arg18

Optional

Variant

At least two Range objects must be specified.

Arg19

Optional

Variant

At least two Range objects must be specified.

Arg20

Optional

Variant

At least two Range objects must be specified.

Arg21

Optional

Variant

At least two Range objects must be specified.

Arg22

Optional

Variant

At least two Range objects must be specified.

Arg23

Optional

Variant

At least two Range objects must be specified.

Arg24

Optional

Variant

At least two Range objects must be specified.

Arg25

Optional

Variant

At least two Range objects must be specified.

Arg26

Optional

Variant

At least two Range objects must be specified.

Arg27

Optional

Variant

At least two Range objects must be specified.

Arg28

Optional

Variant

At least two Range objects must be specified.

Arg29

Optional

Variant

At least two Range objects must be specified.

Arg30

Optional

Variant

At least two Range objects must be specified.

Return Value

Range

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()"
Show:
© 2016 Microsoft