Proper syntax for summing over intersection of named ranges

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,532
Office Version
  1. 365
Platform
  1. Windows
In the table below, the following named ranges are defined:
$A:$ATableLeft
$E:$ETableRight
$1:$1Jan
$2:$2Feb
$3:$3Mar

<tbody>
</tbody>

I need a formula in E1 that will be the equivalent of =sum(B1:D1) but using the named ranges.

R/CABCDE
1Jan37414
2Feb65617
3Mar4138

<tbody>
</tbody>

I've tried as many combinations of row(), column(), address(), cell(), etc., as I can think of, but mostly I get errors.

I know I can accomplish this sum by naming B1:D1 something like "JanRow" and then using "=sum(JanRow)", but I like having the column named refer to the columns just to the left and right of the table so that they move if I add columns. But regardless of alternative solutions, I'd like to know how to do this.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You could do this:

=SUM(OFFSET(TableLeft,,1):OFFSET(TableRight,,-1) Jan)

Although, since your first column appears to be text, you could just use:

=SUM(A1:INDIRECT("RC[-1]",0))
 
Upvote 0
You could do this:

=SUM(OFFSET(TableLeft,,1):OFFSET(TableRight,,-1) Jan)

That works, thanks. I kept trying to generate some form of "=SUM(B1:D1)" using the range names. I think I tried some version of Offset, but when it returned a numeric, instead of an alpha, value for a column, I didn't think it would work.
 
Upvote 0
A​
B​
C​
D​
E​
F​
1​
Jan
3​
7​
4​
14​
2​
Feb
6​
5​
6​
17​
3​
Mar
4​
1​
3​
8​
4​
5​
28​
E5: =SUM(TableLeft:TableRight Jan)
6​
34​
E6: =SUM(TableLeft:TableRight Feb)
7​
16​
E7: =SUM(TableLeft:TableRight Mar)

It would be better (safer) if TableLeft referred to col B.
 
Last edited:
Upvote 0
A​
B​
C​
D​
E​
F​
1​
Jan
3​
7​
4​
14​
2​
Feb
6​
5​
6​
17​
3​
Mar
4​
1​
3​
8​
4​
5​
28​
E5: =SUM(TableLeft:TableRight Jan)
6​
34​
E6: =SUM(TableLeft:TableRight Feb)
7​
16​
E7: =SUM(TableLeft:TableRight Mar)

<tbody>
</tbody>


It would be better (safer) if TableLeft referred to col B.

Why is it safer?

Also, why do you recommend moving TableLeft to Col B, but not moving TableRight to Col D? Col E is the sum, not part of the table.

I used to do as you suggest. I switched to assigning the labels just outside the table so I could add columns anywhere in the table without screwing up the formulas. If TableLeft is assigned to the leftmost column of the actual table and I copy that column to the left, the new column will be outside the table (to the left of TableLeft). There is the opposite problem on the right. I tried to remember to always copy into the table, but I seemed to forget. This way, it works. But the formulas would be a lot simpler your way.
 
Upvote 0
Why is it safer?

Because if col A was a date, it would be added to the sum.

Col E is the sum, not part of the table.

Missed that.

If col A contains text, I would do that like this:

tbl refers to: =INDEX(Sheet1!$1:$1048576, ROW(Sheet1!$A$1) + 1, COLUMN(Sheet1!$A$1) + 1):INDEX(Sheet1!$1:$1048576, MATCH(conZzz, Sheet1!$A:$A), COLUMN(Sheet1!$E$1) - 1)

Select some cell in row 1 and define myRow refers to: =1:1 (no $ signs)

ConZzz refers to: =REPT("z", 255) (in all my workbooks)

That definition allows inserting columns left of B, left of E, above row 2, and at the bottom (and, of course, the interior). Then

A​
B​
C​
D​
E​
F​
1​
Month
Val1
Val2
Val3
Total
2​
Jan
3​
7​
4​
14​
E2: =SUM(tbl myRow)
3​
Feb
6​
5​
6​
17​
4​
Mar
4​
1​
3​
8​
5​
13​
13​
13​
B5: =SUM(tbl myCol)
 
Last edited:
Upvote 0
oops...

Disregard my previous post

Maybe...
=SUM((TableLeft Jan) : (TableRight Jan))-(Jan TableRight)

Assumes col 1 (TableLeft) as text.
If not try:
=SUM((TableLeft Jan) : (TableRight Jan))-(Jan TableRight)-(Jan TableLeft)

M.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

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