- 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
Using theIsEmptyFunction to Check Whether a Cell Is Empty
TheIsEmptyfunction returns a Boolean value that indicates whether a single cell is empty:Trueif empty,Falseif not. The cell must truly be empty for the function to returnTrue. If it contains even just a space that you cannot see, Excel does not consider the cell to be empty:
IsEmpty(Cell)
Say that 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 in column A, it colors in the first four cells of that row (seeFigure 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.4Colored rows separating data.