Count cells from entire row that contain value

This tutorial shows how to count cells from a single row that contain a value through the use of an Excel formula or VBA

Example: Count cells from entire row that contain value

Count cells from entire row that contain value

METHOD 1. Count cells from entire row that contain value

EXCEL

=COUNTA(5:5)
The formula uses the Excel COUNTA function to count the number of non-empty cells from the selected row (row 5).

METHOD 1. Count cells from entire row that contain value using VBA

VBA

Sub Count_cells_from_entire_row_that_contain_value()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'count the number of cells in a single row that have a value
ws.Range("B8") = Application.WorksheetFunction.CountA(ws.Range("5:5"))

End Sub

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("B8") in the VBA code.
Row Reference: Select the row that you want to count from by changing the range reference ("5:5") in the VBA code.

Explanation about the formula used to count cells from entire row that contain value

EXPLANATION

EXPLANATION

This tutorial shows how to count cells from a single row 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 row to count cells from a single row that contain a value. In this example, the formula counts the cells that contain a value from row 5.
FORMULA
=COUNTA(row_reference)
ARGUMENTS
row_reference: The row from which you want to count the cells that contain a value.

RELATED TOPICS

Related Topic Description Related Topic and Description
How to count cells from a single column that contain a value using Excel and VBA methods
How to count cells from a single column that contain numbers (cells that are numeric values) using Excel and VBA methods
How to count cells from a single column that contain text (cells that are text values) using Excel and VBA methods
How to count cells from multiple columns that contain a value using Excel and VBA methods
How to count cells that are greater than a specific value using Excel and VBA methods

RELATED FUNCTIONS

Related Functions Description Related Functions and Description
The Excel COUNTA function returns the number of non-empty cells from a specified range