Count cells from multiple columns that contain value
This tutorial shows how to count cells from multiple columns that contain a value through the use of an Excel formula or VBA
Example: Count cells from multiple columns that contain value
=COUNTA(C:D)
|
The formula uses the Excel COUNTA function to count the number of non-empty cells from the selected columns C and D. In this example the formula will count all of the cells in range (C4:D11) given they contain values and no other cell in columns C and D contain any values.
|
Sub Count_cells_from_multiple_columns_that_contain_value()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'count the number of cells from multiple columns that have a value
ws.Range("F5") = Application.WorksheetFunction.CountA(ws.Range("C:D"))
ws.Range("F5") = Application.WorksheetFunction.CountA(ws.Range("C:D"))
End Sub
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("F5") in the VBA code.
Columns Reference: Select the columns that you want to count from by changing range reference ("C:D") in the VBA code.
Output Range: Select the output range by changing the cell reference ("F5") in the VBA code.
Columns Reference: Select the columns that you want to count from by changing range reference ("C:D") in the VBA code.
Explanation about the formula used to count cells from multiple columns that contain value
EXPLANATION
EXPLANATION
This tutorial shows how to count cells from multiple columns that contain a value using an Excel formula and VBA.
Both the Excel and VBA methods make use of the COUNTA function and selecting an entire columns to count cells from these columns that contain a value. In this example, the formula counts the cells that contain a value in columns C and D.
FORMULA
=COUNTA(column_references)
=COUNTA(column_references)
ARGUMENTS
column_references: The columns from which you want to count the cells that have a value.
column_references: The columns from which you want to count the cells that have a value.
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
Count cells from entire column that contain numbers | How to count cells from a single column that contain numbers (cells that are numeric values) using Excel and VBA methods | |
Count cells from entire column that contain text | How to count cells from a single column that contain text (cells that are text values) using Excel and VBA methods | |
Count cells from entire column that contain value | How to count cells from a single column that contain a value using Excel and VBA methods | |
Count cells if greater than | How to count cells that are greater than a specific value using Excel and VBA methods | |
Count cells if less than | How to count cells that are less than a specific value using Excel and VBA methods |
RELATED FUNCTIONS
Related Functions | Description | Related Functions and Description |
---|---|---|
COUNTA Function | The Excel COUNTA function returns the number of non-empty cells from a specified range |