Excel - COLUMNS Function



COLUMNS Function

The Excel COLUMNS function retrievers the single numeric value representing the total column number. It counts the number of Columns in an array or reference. It is a part of the LOOKUP and REFERENCE function in Microsoft Excel. The COLUMNS function is contrary to the ROWS function. It is a versatile yet powerful function that resolves many case scenarios, such as calculating the sales production of every region worldwide quarterly and being a finance analyst evaluating mutual funds' Compound Annual Growth Rate over 10 years.

Compatibility

This Advanced Excel function is compatible with the following versions of MS Excel −

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel 2024
  • Excel 2024 for Mac
  • Excel 2021
  • Excel 2021 for Mac
  • Excel 2019
  • Excel 2016
  • Excel 2013
  • Excel 2010
  • Excel 2007

Syntax

The syntax of the COLUMNS function is as follows −

=COLUMNS(array)

Arguments

You can use the following arguments with the COLUMNS function −

Argument Description Required / Optional
Array An array formula, a cell reference, and a cell range upon which you are willing to count the number of columns. Required

Points to Remember

  • In Microsoft Excel, the =COLUMNS (1:1) formula retrieves the number of Columns, i.e., 16384.

Examples of COLUMNS Functions

Practice the following example to learn the use of the COLUMNS function in Excel.

Example 1: How to Apply the COLUMNS Function in Excel?

In this example, we will apply the COLUMNS function to calculate the total number of Columns in the specific range of cells.

Solution

Step 1 − First, Deliberate a desired worksheet, select the B3 cell, and write the formula =COLUMNS(1:1).

How to Apply COLUMNS Function in Excel1

After that, press the Enter tab to obtain the resulting value.

How to Apply COLUMNS Function in Excel2

Step 2 − Moreover, write the formula =COLUMNS(D2:E15) in the B4 cell.

How to Apply COLUMNS Function in Excel3

Then, hit the Enter tab to get the resulting value.

How to Apply COLUMNS Function in Excel4

Therefore, the COLUMNS function retrieves the total number of columns, 2

Step 3 − Afterward, select the cell B5 and enter the formula =COLUMNS(D2:T5).

How to Apply COLUMNS Function in Excel5

How to Apply COLUMNS Function in Excel6

Hence, the resulting value is 17.

Step 4 − Similarly, you can calculate the COLUMNS function in the array constant. You may enter the formula =COLUMNS({7,8,9,10;1,4,5,6;11,13,15,16}). In this array formula, there are four entries 7,8,9 19 in the first row, a further four entries in the 1,4,5,6 in the second row, and the third row contains the values 11,13,15 and 16.

How to Apply COLUMNS Function in Excel7

Therefore, the number of columns is 4.

Example 2: Extracting the Last Cell Value in the Array using the INDEX, ROW, and COLUMNS Functions

In this example, the value of the last cell will be extracted by combining the INDEX, ROW, and COLUMNS functions.

Solution

Step 1 − First, assume the sample dataset where the random numbers are specified in the cell range B2:E4.

Step 2 − After that, enter the formula =INDEX(B2:E4,ROW(B3),COLUMNS(A4:D4)) in the C6 cell.

Extracting Last Cell Value in Array1

Explanation

  • In this formula, we have selected the range of cells B2:E4 in the first argument.
  • The ROW(B3) gives the third row of the cell range B2:E4.
  • The COLUMNS(A4:D4) count the number of columns in the cell range A4:D4 and give you the result of 4.
  • In the simpler way, the expression becomes =INDEX(B2:E4,3,4), which means the cell value at the intersection point(3,4) will be extracted from the array.

Finally, hit the Enter tab to get the result, which is 98.

Extracting Last Cell Value in Array2

Download Practice Sheet

You can download and use the sample data sheet to practice the COLUMNS function.

Advertisements