␡
- The Range Object
- Syntax for Specifying a Range
- Named Ranges
- Shortcut for Referencing Ranges
- 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 the Intersect Method to Create a New Range from Overlapping Ranges
The Intersect method returns the cells that overlap between two or more ranges. If there is no overlap, an error will be returned:
Application.Intersect(argument1, argument2, etc.)
The expression Application is not required. The following code colors the overlapping cells of the two ranges:
Set IntersectRange = Intersect(Range("Range1"), Range("Range2")) IntersectRange.Interior.ColorIndex = 6