- The Range Object
- Syntax to Specify a Range
- Named Ranges
- Shortcut for Referencing Ranges
- Referencing Ranges in Other Sheets
- Referencing a Range Relative to Another Range
- Use the Cells Property to Select a Range
- Use the Offset Property to Refer to a Range
- Use the Resize Property to Change the Size of a Range
- Use the Columns and Rows Properties to Specify a Range
- Use the Union Method to Join Multiple Ranges
- Use the Intersect Method to Create a New Range from Overlapping Ranges
- Use the ISEMPTY Function to Check Whether a Cell Is Empty
- Use the CurrentRegion Property to Select a Data Range
- Use the Areas Collection to Return a Noncontiguous Range
- Referencing Tables
- Next Steps
Use the ISEMPTY Function to Check Whether a Cell Is Empty
The ISEMPTY function returns a Boolean value that indicates whether a single cell is empty: True if empty, False if not. The cell must truly be empty for the function to return True. Even if it has a space that you cannot see, Excel does not consider the cell to be empty:
IsEmpty(Cell)
You have several groups of data separated by a blank row. You want to make the separations a little more obvious. The following code goes down the data in Column A. When it finds an empty cell, it colors in the first four cells for that row (see Figure 3.4):
LastRow = Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To LastRow If IsEmpty(Cells(i, 1)) Then Cells(i, 1).Resize(1, 4).Interior.ColorIndex = 1 End If Next i
Figure 3.4. Colored rows separating data.