Sumifs with nested Xlookup-- Adding Indirect to perform calculation across multiple sheets

RR92

New Member
Joined
Jul 29, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I routinely use a sumifs formula with a nested Xlookup to return the column of values I want to sum up: =SUMIFS(XLOOKUP(J$8,'Sheet1'!$C$7:$AN$7,'Sheet1'!$C$8:$AN$220,,0),'Sheet1'!$A$8:$A$220,'Lookup'!$I11)

The formula above works fine. However, when I try to nest the Indirect function to perform the same calculation across multiple worksheets, I get an N/A error (Sheets is a named range of tab names): =SUMIFS(XLOOKUP(J$8,INDIRECT("'"&Sheets&"'!"&"C7:AN7"),INDIRECT("'"&Sheets&"'!"&"C8:AN220"),,0),INDIRECT("'"&Sheets&"'!"&"A8:A220"),'Lookup'!$I29)

When I add the indirect formula to a more basic Sumifs (without the xlookup) formula, it always works. But for some reason I cannot get the Indirect formula to add up the first calculation above across worksheets. Is there something that would prevent the Indirect function from working across sheets with a 3D lookup formula?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Welcome to the MrExcel forum!

3-D formulas are dicey at the best of times. Even in the best of circumstances, you have to get them exactly right, and sometimes there's just no way to do it. In this case, we can, but only if the heading columns on each sheet (C7:AN7) have the headings in the same order on each sheet. Then we can look up the column on the first sheet, then make an INDIRECT string that we can use for all sheets. So if your sheets look like this:

Book4
ABCDEF
7AlphaBetaGammaDelta
8a1234
9b2468
10c36912
11a481216
12b5101520
13c6121824
14a7142128
15b8162432
16c9182736
17d10203040
18d11223344
19d12243648
20
Sheet1


Book4
ABCDEF
7AlphaBetaGammaDelta
8a100200300400
9b200400600800
10c3006009001200
11a40080012001600
12b500100015002000
13c600120018002400
14a700140021002800
15b800160024003200
16c900180027003600
17d1000200030004000
18d1100220033004400
19d1200240036004800
20
Sheet2


You can do this:

Book4
HIJK
7Heading
8Beta
9
10Sheetslookup value1 sheet resultMulti-Sheet result
11Sheet1a24
12Sheet2242424
Lookup
Cell Formulas
RangeFormula
J11J11=SUMIFS(XLOOKUP(J$8,Sheet1!$C$7:$AN$7,Sheet1!$C$8:$AN$220,,0),Sheet1!$A$8:$A$220,Lookup!$I11)
J12J12=SUMIFS(INDEX(Sheet1!C8:AN220,0,MATCH(J8,Sheet1!C7:AN7,0)),Sheet1!A8:A220,I11)
K12K12=LET(ad,"!"&TEXTJOIN(":",,ADDRESS({8,220},COLUMN(C7)+MATCH(J8,Sheet1!C7:AN7,0)-1)),SUM(SUMIFS(INDIRECT(Sheets&ad),INDIRECT(Sheets&"!a8:a220"),I11)))
Named Ranges
NameRefers ToCells
Sheets=Lookup!$H$11:$H$12K12


The J12 formula is a shorter version of your J11 formula. The K12 formula looks up the proper column, performs the SUMIFS on all sheets, sums those amounts, and shows the total. I tried to play with moving the column headings around, but I think that's just too much for Excel to keep track of internally.

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,837
Messages
6,174,927
Members
452,593
Latest member
Jason5710

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