Count cells that are blank
This tutorial shows how to count cells that are blank through the use of an Excel formula or VBA
Example: Count cells that are blank
=COUNTBLANK(C5:C11)
|
This formula uses the Excel COUNTBLANK function to count the number of blank cells in range (C5:C11).
|
Sub Count_cells_that_are_blank()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'apply the formula to count cells that are blank
ws.Range("C13") = Application.WorksheetFunction.CountBlank(ws.Range("C5:C11"))
ws.Range("C13") = Application.WorksheetFunction.CountBlank(ws.Range("C5:C11"))
End Sub
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C13") in the VBA code.
Range: Select the range from which you want to count blank cells by changing the range reference ("C5:C11") in the VBA code.
Worksheet Selection: Select the worksheet which captures a range of cells from which you want to count the number of blank cells by changing the Analysis worksheet name in the VBA code. You can also change the name of this object variable, by changing the name 'ws' in the VBA code.
Output Range: Select the output range by changing the cell reference ("C13") in the VBA code.
Range: Select the range from which you want to count blank cells by changing the range reference ("C5:C11") in the VBA code.
Worksheet Selection: Select the worksheet which captures a range of cells from which you want to count the number of blank cells by changing the Analysis worksheet name in the VBA code. You can also change the name of this object variable, by changing the name 'ws' in the VBA code.
EXPLANATION
Both the Excel and VBA methods use the COUNTBLANK function to count the number of blank cells in a selected range.
Both the Excel and VBA methods use the COUNTBLANK function to count the number of blank cells in a selected range.
FORMULA
=COUNTBLANK(range)
=COUNTBLANK(range)
ARGUMENTS
range: A range of cells from which you want to count the number of blank cells.
range: A range of cells from which you want to count the number of blank cells.
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
If a cell contains text | How to test if a cell contains text and return a specified value using Excel and VBA methods | |
Count cells that contain text | How to count cells that contain text using Excel and VBA methods | |
Count cells that do not contain a specific value | How to count cells that do not contain a specific value using Excel and VBA methods | |
Count cells that contain a specific value | How to count cells that contain a specific value using Excel and VBA methods | |
Count cells that are not blank | How to count cells that are not blank using Excel and VBA methods |
RELATED FUNCTIONS
Related Functions | Description | Related Functions and Description |
---|---|---|
COUNTBLANK Function | The Excel COUNTBLANK function returns the number of empty cells from a specified range |