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.

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


1

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.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Worksheet Events

You can create macros that are automatically executed whenever certain events occur within a worksheet. This tip details ...

Discover More

Using Two Characters as a Drop Cap

Want to add drop caps to your layout? They can provide a nice, appealing design element, but how you actually create the ...

Discover More

Excluding Values from Averaging

Calculating an average of a group of numbers is easy. What if you want to exclude a couple of the numbers from the group ...

Discover More

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!

More ExcelTips (ribbon)

Ways to Concatenate Values

Users of the most recent versions of Excel have four different ways available to combine values into strings. Even those ...

Discover More

Disabling #SPILL! Errors

In the newest version of Excel, a change in how formulas are calculated can cause havoc for some "older" formulas. Here ...

Discover More

Selecting Random Names

Got a ton of names from which you need to select a few random names? There are several ways you can extract what you ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 5?

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.


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.