We may need to count the number of columns in a selection in Excel for a range of purposes including data validation, manipulation, management, organization, etc. It is helpful while creating charts and visualization purposes too. It gives a general idea about a dataset and the number of particulars involved. In this tutorial, we will focus on how to count the number of columns in Excel using different techniques.
Download Practice Workbook
You can download the workbook used for the demonstration from the link below.
How to Count Number of Columns in Excel: 5 Suitable Examples
Excel offers some easy ways to count the number of columns, both in a range and throughout the whole worksheet. We will go through them one by one in their own sub-sections. For the demonstration, we are using the following dataset containing six person’s sales data of an organization.
We will be using Excel 365 for all the demonstrations.
1. Using Status Bar to Count Number of Columns in Excel
The status bar is the horizontal bar displaying information at the bottom of the Excel spreadsheet. It contains and provides helpful information, and can give quick access to various useful settings and features. We can use this feature to count the number of columns in Excel quite easily.
- Select the headers of the chart or dataset (or a particular row, which doesn’t have any empty cells) that you want to measure the number of columns. This is important to not select the whole dataset or more than a row here. We have selected the range B4:E4 which contains the headers here.
- Now, observe the status bar. The number of columns available there will show as Count in it.
Note: The Count in the status bar only shows the non-empty cells in a selection.
2. Count Number of Columns in Range Using COLUMNS Function
Excel provides the COLUMNS function to achieve the same result too. Although the previous method is the quickest, you can select any number of rows using the function.
The COLUMNS function takes an array as the argument and returns the total number of columns used there.
- To count the number of columns in Excel with the function, select cell C12 and insert the following formula.
- You can use the range B4:E10 (whole dataset) as an argument too and get the same result.
Read More: How to Count Columns until Value Reached in Excel
3. Count Total Number of Columns Available on Entire Sheet from Column Index
You can count the total number of columns available in the entire worksheet in Excel too. You can easily count them from the column index. For this to work, the select cell’s row should be empty.
- Select the very first cell (cell A1) on the spreadsheet.
- Then press Ctrl+Right Arrow on your keyboard. The index number showing on the top of the last one is the total columns available in the spreadsheet.
- If you want to see it in numbers, go to File > Options. Then go to the Formulas tab and under the Working with formulas section, check the R1C1 reference style.
- After clicking on OK, you will have numbers in the column index and see the spreadsheet has 16384.
Note: If you are selecting a cell that does not belong to an empty row, select a cell that doesn’t contain any values on the right of it and press Ctrl+ Right Arrow.
Count Total Number of Columns Available in Entire Sheet Using COLUMNS Function
You can use the COLUMNS function to count the total number of columns available in Excel too. As mentioned earlier, the function takes an array and gives the total number of columns available in that array. So if we pass up an entire row as the array argument, it will return the total column number of the sheet.
- For an entire row, the formula should be like this.
As we can see, we can get the same value 16384, which indicates the total number of columns available in the sheet.
Read More: How to Find Column Index Number in Excel (2 Methods)
4. Using COUNTA Function to Count Number of Columns with Entries
Excel’s COUNTA function provides users with the non-blank values it takes as the argument. Keep in mind, it returns the total number of cells in the selection that are not empty. We can utilize this feature to pass only the column headers or a row without any empty cells as the argument and get our desired result.
- The formula should look like this.
As we can see the result is the same as the previous methods. However, the selection should be similar to the first method.
5. Using VBA to Count Number of Columns of Selected Range in Excel
To count the number of columns in Excel using VBA, we have to create a custom function.
However, you need to have the Developer tab on your ribbon first. If you don’t have one, click here to find out how to display the Developer tab on your ribbon.
- Go to the Developer tab and click on Visual Basic from the Code group of the ribbon.
- Now click on the Insert tab in the VBA window and select Module from the drop-down menu.
- In the newly created module, insert the following code.
Function NumberofColumns(rnge As Range) As Integer NumberofColumns = rnge.Columns.Count End Function
- Now close the VBA window and insert the following formula in the spreadsheet.
- We can use more than the headers as the argument too for this UDF, such as the range B4:E10. You can use the following formula and get the same result.
- Additionally, we can use this function to determine the total number of columns available in the sheet too. Modify the formula in this way.
This is how we can use VBA to count the number of columns in Excel.
How to Count Number of Rows in Excel
We can count the number of rows in Excel in the same way as when we count the columns. Selecting the row headers or a column of a dataset that does not have any empty cells within it will show the row number as the count in the status bar. However, we need the ROWS function to count the number of rows in Excel, instead of the COLUMNS function.
- To count the number of rows in the selection, use the formula like this.
- The function can be used to find out the total number of rows available in the spreadsheet too.
How to Get Column Number of Selected Cell in Excel
Besides the COLUMNS function, Excel also offers the COLUMN function. The difference is the COLUMN function returns the count of the column of the reference or array in the spreadsheet. Just for the purpose of finding out the column number, it may not be effective as we can see that easily from the column index. However, there are many important uses of the function. That includes constructing it with other functions, uses in conditional formatting, and many different array formulas.
- The formula can be used like this.
- We can use it for a range too, in those cases it will return an array. For example, we have used the following formula in cell D13.
These values do not have any direct practical uses but are used as references in other formulas.
Frequently Asked Questions (FAQs)
- How to Insert Extra Rows and Columns in Excel?
To insert an extra row or columns in Excel, right-click on the column or row index and select Insert from the context menu. If you do so from the column index, Excel will insert an extra column. Otherwise, you will get an extra row in between. Be sure to right-click on the column/row index before which you want the extra column/row to insert.
- Is there a formula or function to automatically count the number of columns in a table?
The COLUMNS function described in method 2 can be used for tables too. For tables, the argument selected manually will automatically be converted into a dynamic range and it will count the number of columns on its own if there are any changes.
- How do I count the number of columns with data in a specific row?
You can use the COUNTA function to find out the number of non-empty cells in any range. You can use this to count the number of columns with data in a specific row. For example, let’s say for the third row, using =COUNTA(3:3) will give the number of cells with values in the row.
Things to Remember
- All methods of counting ranges can be applied to tables too.
- Make sure to select only the headers if you are applying the status bar method or the COUNTA.
- If you are not selecting the header, make sure all the cells in the row are non-empty.
- Use the COLUMNS function to get the number of columns and the COLUMN function to get the column index of the selection.
That concludes our article on how to count the number of columns in Excel which includes the status bar, functions, and VBA. Usually, the methods are pretty straightforward. But I hope you found what you were looking for and can count the number of columns for both the selection and spreadsheet in Excel comfortably now. Hopefully, you have found the article helpful and effective. If you have any questions or suggestions, let us know in the comments below.