␡
- The Range Object
- 语法指定一个范围
- Named Ranges
- Shortcut for 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
This chapter is from the book
Using theUnionMethod to Join Multiple Ranges
TheUnionmethod enables you to join two or more noncontiguous ranges. It creates a temporary object of the multiple ranges, which enables you to affect them together:
Application.Union(argument1,argument2, etc.)
The expressionApplicationis 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