Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Determining Columns in a Range.
Written by Allen Wyatt (last updated June 27, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
One of the handy worksheet functions provided by Excel allows you to determine the number of columns in a range. This is accomplished through the use of the COLUMNS function. For instance, consider the following formula:
=COLUMNS(B2:D15)
The value returned is 3, since the range includes columns B, C, and D. You are not limited to address ranges (such as B2:D15); you can also use named ranges with the COLUMNS function.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10206) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Determining Columns in a Range.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
Indirect references can be very helpful in formulas, but getting your head around how they work can sometimes be ...
Discover MoreIf you need to count the number of blank cells in a range, the function to use is COUNTBLANK. This tip discusses the ...
Discover MoreIf you need to insert into a cell the name of the workbook in which a worksheet is contained, you can use the CELL ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-06-29 10:43:52
Ken C
Wow! I just realized that the COLUMNS function can be used in a VLOOKUP so that you don't have to count columns. For example:
=VLOOKUP($A2,Sheet2!$A$2:$E$9999,(COLUMNS(A:E)),FALSE)
Could be handy when you have a lot of columns.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments