COLUMNS()

Syntax. COLUMNS(array)

Definition. This function returns the number of columns of an array or cell reference.

Arguments

Background. If you try to use a discontiguous range as the argument, you will get the error message, “You’ve entered too many arguments to the function.” If you enclose these arguments in additional parentheses, you get the #REF! error. If the range is defined by intersections and the intersection is empty, you get the #NULL! error.

Array constants are numbers or text that you must enclose in braces. Rows are separated by semicolons, and columns are separated by commas. The simple expression {1;2;3;4} is interpreted as a single column, as shown by the result of

=COLUMNS({1;2;3;4})

The expression {11,12,13;21,22,23} indicates three columns, as shown by the result of

=COLUMNS({11,12,13;21,22,23})

Example. With this function and the ROWS() function, you can access selected cells in a named range. This is especially useful if you use a dynamic range. You can find more examples in the section for the OFFSET() function later in this chapter.

Assume that a range has the name MyRange. In this case, the formula

=INDEX(MyRange,ROWS(MyRange),COLUMNS(MyRange))

returns a reference to the lower-right cell of the range.

See Also

COLUMN(), ROWS()