
Count how many columns are in a range or array. COLUMNS is useful for measuring width, building horizontal counters, and checking table limits.
The COLUMNS function returns the number of columns in a range or array. If a range is 5 columns wide, COLUMNS returns 5. It counts the size of the range, not the amount of data inside it.
That makes COLUMNS useful when a formula needs to know the width of a table, array, or spill range. It is often used for size checks, horizontal counters, and formulas that need to stay inside the width of a source range.
Useful when a formula needs the width of a range instead of the column number of one cell.
Returns a whole number such as 1, 5, or 16384.
=COLUMNS(array)
The function needs one argument: the range or array you want to measure. For example, =COLUMNS(A1:E1) returns 5. If the range is vertical, like A1:A50, the result is 1 because there is only one column.
COLUMNS can also work with array constants and spilled ranges, so it fits both simple worksheets and newer Excel formulas.
The argument is required. Unlike COLUMN(), COLUMNS does not default to the current cell. It always needs a range or array because the function is measuring size, not position.
COLUMNS is about width. Related functions answer different questions.
| Function | Main Question | Returns | Use When |
|---|---|---|---|
COLUMNS |
How many columns are here? | Count | You need the width of a range |
COLUMN |
Which column is this? | Position number | You need a column index, not a count |
ROWS |
How many rows are here? | Count | You need the height of a range |
COUNTA |
How many non-empty cells are here? | Count | You want to count entries, not physical width |
The most direct use of COLUMNS is measuring the width of a range. A formula can use that count to check whether a table has the expected number of fields, or to decide how far another formula should move across a source range.
COLUMNS is also useful for building a running horizontal counter. A pattern like =COLUMNS($A$1:A1) returns 1 in the first position, then 2, then 3 as the formula is filled to the right. Because the second part of the range expands horizontally, the count grows with it.
Another practical use is boundary checking. If a formula depends on a valid column number inside a source range, COLUMNS can tell you how many columns are available before the formula goes too far. That makes it useful in INDEX-based formulas and other setups where the width of the source range matters.
This formula returns the width of the range, not the number of filled cells. If the range runs from column A to column E, COLUMNS returns 5. This is useful when a worksheet needs to know the physical width of a table.
=COLUMNS(A1:E1) // Returns 5
Count the number of columns in A1:E5. Formula: =COLUMNS(A1:E5).
When a formula spills across multiple columns, COLUMNS can measure the width of that live result with the # operator. That is helpful in newer Excel models where the result width may change over time.
=COLUMNS(B1#) // Returns the current spill width
Count the number of columns in a full row. Formula: =COLUMNS(1:1).
COLUMNS also works with array constants. In {1,2,3;4,5,6}, there are three vertical positions across, so the function returns 3. This is useful when a formula includes a fixed array inside it.
=COLUMNS({1,2,3;4,5,6}) // Returns 3
Count the columns in the array {1,2,3;4,5,6}. Formula: =COLUMNS({1,2,3;4,5,6}).
The range $A$1:B1 starts at a fixed left column and expands across. That means COLUMNS returns 2 here. If the formula is copied one column to the right, the range becomes wider and the result increases automatically.
=COLUMNS($A$1:B1) // Returns 2
Count how many columns are in H1:L1. Formula: =COLUMNS(H1:L1).
Tell your friends about this post