␡
- The Range Object
- Using the Top-Left and Bottom-Right Corners of a Selection to Specify a Range
- 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 Quickly Select a Data Range
- Using the Areas Collection to Return a Non-contiguous Range
- Next Steps
This chapter is from the book
Using the IsEmpty Function to Check Whether a Cell Is Empty
The IsEmpty function returns a Boolean value of whether a single cell is empty or not; True if empty, False if not. The cell must truly be empty. Even if it has a space in it, which you cannot see, Excel does not consider it empty:
IsEmpty(Cell)
Look at Figure 3.5. You have several groups of data separated by a blank row. You want to make the separations a little more obvious.
Figure 3.5 Blank empty rows separating data.
The following code goes down the data in Column A and where it finds an empty cell, colors in the first four cells for that row (see Figure 3.6):
LastRow = Range("A65536").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.6 Colored rows separating data.