absolute cell reference

justme

Well-known Member
Joined
Aug 26, 2002
Messages
729
in column C I have a formula which is the sum of column D to column AA.
=IF(SUM($D5:zz5)<>0,SUM($D5:zz5),"")

Problem: Every day I insert a column next to column C, which becomes the new column D and my formula changes to =IF(SUM($E5:AAA5)<>0,SUM($E5:AAA5),"")

How can I keep the cell reference $D in the formula?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try this out:

=IF(SUM(INDEX(5:5,,4):ZZ5)<>0,SUM(INDEX(5:5,,4):ZZ5),"")
 
Upvote 0
Works, will play a little to figure out. THANKS

To explain a bit how it works, the INDEX formula returns a range reference which can be used anywhere you would normally refer to a range. The goal was to have the first range reference ALWAYS be D5. There were two ways to accomplish this:
  1. Use an INDIRECT formula
  2. Use an INDEX formula
The INDIRECT formula approach is for a last-resort, as INDIRECT is a volatile function (updates when ANY calculation is performed - very ineffecient). The INDEX function will only update when one of its precedents are updated (the cells actually referenced in the INDEX formula).

So to further explain INDEX, it has the syntax:
INDEX(array, [row number], [column number])

We define the array argument to be 5:5 (aka, the entire row 5). Now, we need to tell the formula what cell we want to return. We can omit the [row number] argument, since this is a 1-dimensional array. Now, we want to tell the formula to return the fourth column (since D is the fourth column), so we put a 4 in for the [column number] argument.

As a result, INDEX(5:5,,4) will always point to D5, no matter how many columns you insert in your data. However, keep in mind that if you add rows above that formula, the range it references will be adjusted. So if you were to add a row above it, the formula will change itself to INDEX(6:6,,4).

Hope that explanation helps! Glad it works for you. ;)
 
Upvote 0
=SUM(INDEX(3:3,,sales!4:AA3))


So, to carry this conversation further, I want to do exactly the same thing, but on the summary page. Excel doesn't seem to like that. I get a #VALUE! error. The formula above is in cell B3 in Sheet1, which is the summary page for the sheets named Sales and Orders.
 
Upvote 0
The part I have highlighted below is not only incorrect syntax, but also not a valid range reference:
=SUM(INDEX(3:3,,sales!4:AA3))

If you want it to return column D, then that argument needs to be 4:
=SUM(INDEX(3:3,,4))
 
Upvote 0
Thanks for your reply, but how do I get it to know I want the information from the sales page, not the summary page?
 
Upvote 0
Thanks for your reply, but how do I get it to know I want the information from the sales page, not the summary page?
What do you mean? Can you please elaborate on exactly what you want this formula to do?
 
Upvote 0
I want the formula to give me the sum of row 3, from column D forward on the sheet labeled Sales. The formula will reside in in the sheet now called Sheet1.
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top