Referring to ranges
- By Bill Jelen and Tracy Syrstad
- 3/11/2022
Contents
×
- The Range object
- Referencing ranges in other sheets
- Referencing a range relative to another range
- Using the Cells property to select a range
- Using the Offset property to refer to a range
- Using the Resize property to change the size of a range
- Using the Columns and Rows properties to specify a range
- Using the Union method to join multiple ranges
- Using the Intersect method to create a new range from overlapping ranges
- Using the IsEmpty function to check whether a cell is empty
- Using the CurrentRegion property to select a data range
- Using the Areas collection to return a noncontiguous range
- Referencing tables
- Next steps
Using the Union method to join multiple ranges
The Union method enables you to join two or more noncontiguous ranges. It creates a temporary object of the multiple ranges, which enables you to affect them at the same time:
Application.Union(argument1, argument2, etc.)
The expression Application is not required. The following code joins two named ranges on the sheet, inserts the =RAND() formula, and bolds them:
Set UnionRange = Union(Range("Range1"), Range("Range2")) With UnionRange .Formula = "=RAND()" .Font.Bold = True End With