Excel SUMIFS公式参考其他工作簿

问题描述 投票:0回答:1

我正在尝试编写一个VBA代码,该代码将填充我的Excel SUMIFS公式。通常,SUMIFS将基于其他工作簿数据来计算总和。当前,其他工作簿文件名在我的宏中进行了硬编码,但是我想使其更加灵活,而不是对其进行硬编码,我想使用一个放置文件名的单元格。

到目前为止,宏将创建以下公式并将其放在单元格中:

=SUMIFS([SW.xlsx]TeamAllocations!F$9:F$401,[SW.xlsx]TeamAllocations!$D$9:$D$401,$D16,[SW.xlsx]TeamAllocations!$B$9:$B$401,$B16)

我想要的东西有点像:

=SUMIFS([<variable evaluated based on a cell which has filename/filepath, eg B1>]TeamAllocations!F$9:F$401,[<variable evaluated based on a cell which has filename/filepath, eg B1]TeamAllocations!$D$9:$D$401,$D16,[<variable evaluated based on a cell which has filename/filepath, eg B1]TeamAllocations!$B$9:$B$401,$B16)

因此,在B1单元格中,我将具有“ SW_01.xlsx”或“ SW_02.xlsx”,因此SUMIFS公式将始终具有最新的信息。在Excel中有可能吗?

谢谢J。

excel vba excel-formula sumifs
1个回答
0
投票

如果所有文件都具有固定格式,我想您可以将所有文件与强力查询结合起来。您可以更轻松地完成所需的操作。

合并文件:

https://chandoo.org/wp/combine-excel-files-using-power-query/

PowerQuery中的组(与SUMIF相同:]

https://support.office.com/en-us/article/group-rows-in-a-table-power-query-e1b9e916-6fcc-40bf-a6e8-ef928240adf1

有用的过滤器:

https://exceleratorbi.com.au/pass-excel-parameter-power-query/

© www.soinside.com 2019 - 2024. All rights reserved.