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: Finding the Sum of a Sequential Integer Range.

Finding the Sum of a Sequential Integer Range

Written by Allen Wyatt (last updated June 8, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


2

Excel includes the FACT worksheet function which returns the factorial of a value. (The factorial of the number X is the result of multiplying 1 * 2 * 3 ... * X.) Sabeesh wonders if there is a similar function that will return the sum of the values (1 + 2 + 3 ... + X) instead of the result of the values.

There is no such function built into Excel, but a quick mathematical formula will do the trick. The proper terminology to refer to this type of sum is a "triangular number." This derives from the fact that if the sum was represented with objects, they could always be arranged in the form of a triangle. For example, if you had 5 objects on the bottom row, 4 on the next, 3 three on the third, 2 on the fourth, and 1 on the top row, you have a triangle. Summing the number of objects (5 + 4 + 3 + 2 + 1) is what Sabeesh wants to do.

The answer to this problem can be expressed as a mathematical formula, reportedly discovered by Carl Friedrich Gauss. (Which is the source for another name of this type of number: a Gaussian Summation.) Note that the sum of opposite rows in the above example are always the same: 5 + 1 is the same as 4 + 2. This is true regardless of the number of rows; if there were 100 rows, then 100 +1 is the same result as 99 + 2, 98 + 3, 97 + 4, etc. What you end up with is 50 "pairs" of numbers equal to 1 more than the upper limit of your range.

The upshot of all this—without going through a lot of explanation—is that you can find the triangular number for any positive value (where you start at 1 and end with X) in the following manner:

=X*(X+1)/2

Thus, if you had a number in cell A1 and you wanted to know the sum of the range of 1 through that number, you could use this formula:

=A1*(A1+1)/2

This formula provides a simple way to determine the sum required, without the necessity of resorting to using a macro.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9998) 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: Finding the Sum of a Sequential Integer 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

Placing Formula Results in a Comment

Excel won't allow you to directly or automatically insert the results of a formula into a cell's comment. You can, ...

Discover More

Understanding the Start Menu

When you want to start using Windows for real, you'll typically need to go through the Start menu to do it. This tip ...

Discover More

Getting Input from a Text File

You can use a macro to read information from a text file. The steps are easy, and then you can use that information in ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Adding a Missing Closing Bracket

When working with large amounts of data, it is a good idea to make sure that the data all consistently follows a pattern. ...

Discover More

Understanding Operators

At the heart of working with Excel is the process of creating formulas that calculate results based on information within ...

Discover More

Dealing with Long Formulas

If your worksheet formulas seem to go on forever, here's a handy way to make them more understandable. (All you need to ...

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 1 + 1?

2023-06-10 06:26:27

Mike J

@Bill Multack

This is an old thread, but I think your first formula should be

=(Y*(Y+1) - X*(X-1))/2

assuming one is summing the numbers X to Y inclusive.


2019-06-29 19:20:43

Bill Multack

To find the sum of numbers from one integer to another, one can use this formula: [assumes Y>X] =(Y*(Y-1) - X*(X-1))/2.
If A1 and A2 contain the intergers (A2 larger) then the entry to find the sum from A1 to A2 could look like this: =(Y^2 + Y -X^2 + X)/2.


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.