COLUMNS

The COLUMNS function returns the number of columns included in a specified collection of cells.

COLUMNS(range, headers)

range: A collection of cells. range must contain a reference to a single range of cells, which may contain any values.

headers: An optional modal value specifying whether to include header columns in the count of columns.

include-headers (0 or omitted): Include header columns in the count of columns.

exclude-headers (1): Exclude header columns from the count of columns.

Notes

Examples

=COLUMNS(B3:D10) returns 3, the number of columns in the collection specified by the range (columns B, C, and D).

=COLUMNS(5:5) returns the total number of columns in row 5.

=COLUMNS(A1:D10,0) returns 4, the number of columns in the collection specified by the range (columns A, B, C, and D), including the header column A.

=COLUMNS(A1:D10,1) returns 3, the number of columns in the collection specified by the range (columns A, B, C, and D), excluding the header column A.

See also
ROWS