Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. 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: Incrementing References by Multiples when Copying Formulas.

Incrementing References by Multiples when Copying Formulas

by Allen Wyatt
(last updated November 30, 2013)

3

Tim has a worksheet in which cell B1 contains the formula =SUM(A1:A7). He wants to copy this formula down and have the range incremented by 7 rows, so that cell B2 would contain the formula =SUM(A8:A14), cell B3 would contain =SUM(A15:A21), etc. The problem is that when he copies it down, each "end" of the range is only incremented by 1 where it should be incremented by 7 to fulfill his need. He wonders how he can make Excel do the proper incrementing.

You can't make Excel do the proper incrementing using copy and paste; it just won't do it. The reason is simple—there are times when incrementing by 1 makes sense from a formulaic perspective. Since Excel can't read your mind (at least until the next version :>)), it makes the assumption that it should only increment by 1.

The solution is to change your formula. Using a couple of worksheet functions you can have Excel construct the desired range for the summation. Consider the following example of a formula that will provide the desired sum:

=SUM(INDIRECT("A" & (ROW()-1)*7+1 & ":A" & (ROW()-1)*7+7))

If you put this formula into cell B1, it works because it takes a look at the row number (returned by the ROW function) of the row in which the formula is contained. Since it is in row 1, then the formula is evaluated in this manner by Excel:

=SUM(INDIRECT("A" & (ROW()-1)*7+1 & ":A" & (ROW()-1)*7+7))
=SUM(INDIRECT("A" & (1-1)*7+1 & ":A" & (1-1)*7+7))
=SUM(INDIRECT("A" & 0*7+1 & ":A" & 0*7+7))
=SUM(INDIRECT("A" & 0+1 & ":A" & 0+7))
=SUM(INDIRECT("A" & 1 & ":A" & 7))
=SUM(INDIRECT("A1:A7"))
=SUM(A1:A7)

What you end up with in B1 is the sum you desired. (The INDIRECT function uses the value in the string as if it was a real range, which is what you want.) When you copy the formula down the column, as the row number increments the formula provides the proper increments of 7 on both ends of the range.

There are other variations on this technique that you can use. The only difference is that the variations use different worksheet functions to accomplish the same task. For instance, the following variation still uses the ROW function, but then ultimately relies on the OFFSET function to calculate the desired range:

=SUM(OFFSET(A1,((ROW()-1)*6),0):OFFSET(A7,((ROW()-1)*6),0))

A shorter approach that uses OFFSET is as follows:

=SUM(OFFSET($A$1,ROW()*7-7,0,7,1))

Regardless of the approach, you can probably tell that the idea is to come up with a formula that uses the row in which the formula appears in order to construct the range that you really want. Each of the examples so far assumes that you are starting in cell B1. If you want to start in cell B2, then you'll need to modify the formulas to account for whatever row you are starting on. To give you just an idea of how this works, if you were starting in cell B2, instead, the three formulas presented in this tip would be modified in the following ways:

=SUM(INDIRECT("A" & (ROW()-2)*7+2 & ":A" & (ROW()-2)*7+8))
=SUM(OFFSET(A2,((ROW()-2)*6),0):OFFSET(A8,((ROW()-2)*6),0))
=SUM(OFFSET($A$2,(ROW()-1)*7-7,0,7,1))

Start at a different location, and you'll need to make further modifications to the formula you choose to use.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8387) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Incrementing References by Multiples when Copying Formulas.

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

Sorting Files

The Open dialog box allows you to sort the files it presents to you. How you do the sorting depends on the version of Word ...

Discover More

Pulling Tables Back Into View

If you make structural changes to your table by adding new columns here and there, you could easily end up with a table that ...

Discover More

Avoiding Rounding Errors in Formula Results

Some formulas just don't give the results you expect. Sometimes this is due to the way that Excel handles rounding. Here's ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Finding Odd Values Greater Than 50

If you have a special need to find cell values that meet two different criteria, where to start can be daunting. This tip can ...

Discover More

Automatically Numbering Rows

Adding row numbers to a column of your worksheet is easy; you just need to use a formula to do it. Here's a quick look at a ...

Discover More

Finding the Address of the Lowest Value in a Range

Uncovering the lowest value in a range is relatively easy; you can just use the MIN worksheet function. Discovering the ...

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. 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 three minus 2?

2015-09-17 12:46:55

Kate

How would this formula work if I wanted to look across columns for the data rather than down rows. I have figures per day across row E10:K10,L10:R10 etc and I want to sum on a separate totals page every 7 days of costs into w/e cost. I have tried amending but can't get it to work consistently


2015-08-20 04:21:49

Lau Hestbek

To make your formula independent of where you place it you can put "A1" or "1:1" in the row-function.

In your example [ =SUM(OFFSET($A$1,ROW()*7-7,0,7,1)) ] this means that you can write it as:

=SUM(OFFSET($A$1,ROW(1:1)*7-7,0,7,1))

Or

=SUM(OFFSET($A$1,ROW(A1)*7-7,0,7,1))


A huge problem with this (and your) approach though is that the formula changes if you insert a new row on top. Also as Bryan points out, the OFFSET- and INDIRECT-functions are volatile.


2013-12-02 11:20:39

Bryan

One thing to think about is whether a SUMIF or SUMIFS formula will help you here. If you are summing in groups of 7, I'm guessing there's a date invloved and you are summing by week.

However, taking the question at face value, there is another way to do it that doesn't use the volatile INDIRECT or OFFSET functions. The INDEX function also provides a reference to another cell, but is not volatile. Knowing that, you can use the following equation:

=SUM(INDEX(A:A,(ROW()-1)*7+1):INDEX(A:A,ROW()*7))

So to do the analysis like Allen did for row 1:

=SUM(INDEX(A:A,(ROW()-1)*7+1):INDEX(A:A,ROW()*7))
=SUM(INDEX(A:A,(1-1)*7+1):INDEX(A:A,1*7))
=SUM(INDEX(A:A,1):INDEX(A:A,7))
=SUM(A1:A7)


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.