COLUMNS Function in Excel

For example, the formula =COLUMNS(A1:C3) will return as 3 since the range A1:C3 has 3 columns.

Syntax

The COLUMNS function has only one argument. When,

  • array = This is a required parameter. An array / a formula resulting in an array / a reference to a range of Excel cells for which the number of columns is to be calculated.

How to use COLUMNS Formula in Excel?

The said function is a Worksheet (WS) function. As a WS function, columns can be inserted as a part of the formula in a worksheet cell. You may refer to the examples given below to understand better.

Let us look at the column examples given below. Each example covers a different use case implemented using the COLUMNS function.

Example 1 – Total columns in a range

In the example of this column, cell G3 has a formula associated with it. So, G3 is a result cell. The argument for COLUMNS function in excel is a cell range, which is B4:D4. Here, B4 is a starting cell, and D4 is the ending cell. The number of columns in between these two cells is 3. So, the result is 3.

Example 2 – Total cells in a range

In this example, cell G4 has a formula associated with it. So, G4 is a result cell. The formula is COLUMNS (B4: E8) * ROWSB4: E8). Then, multiplication is performed between the total number of columns and a total number of rows for the given range of cells in the sheet. Here, the total number of columns is four, and the total number of rows is 5. So, the total number of cells is 45 = 20.

Example 3 – Get the address of the first cell in a range

Here, the dataset is named “data.” Further, this “data” is used in the formula. You may refer to the steps given below to name the dataset.

  • Step#1. Select the cells.Step#2. Right-click and choose “Define Name.”Step#3. Name the dataset as “data.”

In the example of these columns, cell G6 has a formula associated with it. So, G6 is a result cell. The formula is to calculate the first cell in the dataset represented by the name “data.” The result is $B$4, i.e., B4, the last cell in the selected dataset.

The formula uses the ADDRESSES function, which has two parameters: row number and column number.

E.g., ADDRESS (8,5) returns $B$4. Here, 4 is the row number, and 2 is the column number. So, the function returns a cell denoted by these row and column numbers.

Here,

A row number is calculated by

ROW(data)

And the column number is calculated by

COLUMN(data)

Example 4 – Get the address of the last cell in a range

Here, the dataset is named “data.” Further, this “data” is used in the column’s formula in Excel. Finally, you refer to the steps given below to name the dataset.

In this COLUMNS example, cell G5 has a formula associated with it. So, G5 is a result cell. The formula is to calculate the last cell in the dataset represented by the name “data.” The result is $E$8, i.e., E8, the last cell in the selected dataset.

E.g., ADDRESS (8,5) returns $E$8. Here, 8 is the row number, and 5 is the column number. So, the function returns a cell denoted by these row and column numbers.

ROW(data)+ROWS(data-1)

COLUMN(data)+COLUMNS(data-1)

Things to Remember

  • The argument of the COLUMNS function in Excel can be a single cell address or a range of cells.The argument of the COLUMNS function cannot point to multiple references or cell addresses.

Columns Function in Excel Video

This article has been a guide to Columns Function in Excel. We discuss using the columns function, practical examples, and downloadable Excel templates here. You can also go through our other suggested articles: –

  • Excel Column LockExcel Freeze ColumnsGroup Column in ExcelColumn in ExcelBreak Links in Excel