Skip to content

COLUMNS function

Overview

The COLUMNS function in IronCalc is a lookup & reference formula that is used to query and return the number of columns referenced in a particular range or array.

Usage

Syntax

COLUMNS(reference) => columns

Argument descriptions

  • reference (cell). The cells, columns, array, range, or Named Range which you wish to evaluate.

Additional guidance

  • When using COLUMNS a reference must be included.
  • You are able to reference either complete columns or individual cells.
  • When referencing Named Range, the complete column must have the label. Referencing individual cells using Named Ranges in COLUMNS is not supported.
  • When using a Named Range as a reference, the reference is not case sensitive.
  • IronCalc supports the use of both Absolute ($A$1) and Relative (A1) references.
  • Cross-sheet references are also supported.
  • When referencing a range of columns or cells, if a cell or column within the range is deleted the count will automatically adjust. However, if the cell or column that is explicitly referenced is deleted an error will be thrown.

Returned value

COLUMNS returns the number of columns which are being referenced.

Error conditions

  • #ERROR! is returned if no reference is included.
  • #NAME? is returned if a Named Range being referenced is deleted.
  • #REF! is returned if a cell being referenced is deleted.
  • #VALUE! is returned if a column being referenced is deleted.
  • #VALUE! is returned if a cell name is being referenced.
  • #VALUE! is returned when referencing a Named Range in combination with an additional cell or column.

Details

The COLUMNS function can only be used to display the correlating number of columns being referenced. If you wish to show the number of a single column within a Sheet, you can use the COLUMN function.

Examples

Basic Range

When a range of cells is referenced, only the number of columns will display.

For example =COLUMNS(A1:C1) and =COLUMNS(C1:E1) will both output a value of "3".

Named Ranges

When using COLUMNS, Named Ranges can only be referenced individually and not in combination with other cells or columns.

For example, =COLUMNS(Range1) will output the amount of columns contained within your Named Range. An error will be returned if you try to reference anything else within the paranthesis.

Single Cell & Single Column References

When a single cell is referenced, such as =COLUMNS(G1), an Output of "1" will always be the result. This result will also return when referencing single columns, for example =COLUMNS(G:G).