Forum Discussion

mark_snowdowne's avatar
mark_snowdowne
Copper Contributor
Sep 01, 2020

sumproduct on a closed workbook with dynamic sheet and file names

Thanks for reading.
I'm using the sumproduct function to https://www.excelforum.com/excel-formulas-and-functions/1060824-sumifs-returning-value-on-closed-workbook.html

This works fine:

=SUMPRODUCT(
--('[Civil Estimate - Division 2.xlsm]Div. 2'!$AE:$AE=$C1),
'[Civil Estimate - Division 2.xlsm]Div. 2'!$Y:$Y)

 

What I want to do is have dynamic tab names and if possible dynamic file names.

The files are called "Estimate - Division 2", "Estimate - Division 3", etc.
They each have sheets in them named Div. 1, Div. 2, etc.

cell C1 = lookup code

cell S1 = Division #


My attempt:

=SUMPRODUCT(
--(INDIRECT("'C:\4. Files\[Estimate Division "&S1&".xlsm]Div. "&S1&"'!$AE:$AE")=$C1),
(INDIRECT("'C:\4. Files\[Estimate - Division "&S1&".xlsm]Div. "&S1&"'!$Y:$Y")))

 

cell C1 = lookup code

cell S1 = Division #

 

It works, but only if the workbook is open... which defeats the purpose of using sum product to mimic a sumif funciton.

 

I'm terrible with indirect functions. Any help is appreciated. Thanks!

Resources