首页 > 解决方案 > VBA Sumproduct 返回#value!on cell - 如何修复我的代码以避免此错误?

问题描述

我有一个工作簿,其中有大约 80 个其他工作簿的链接。加载速度真的很慢。我决定停止使用链接来加快速度。这意味着找到一种方法来使用 VBA sumproduct 来执行一些计算。我现在很头疼,因为我得到了#Value!我的 VBA 代码中的错误。

 option explicit

Sub VBA_Sumproduct

Dim rng_1 as range

Dim op_cell as range

Dim Model as String

Dim formula as string

Dim wb as workbook

dim wb2 as workbook

set wb2 = workbooks("wb2.xlsm")

'workbooks.open("Filepath")

set wb = workbooks("wb1.xlsm")

set rng_1=wb.sheets("A1").range("E2:E500")

set op_cell = wb2.sheets("T1").range("E20")

model = "Complete"

Formula = "sumproduct((rng_1="" & model & "")"

op_cell = application.evaluate(Formula)

wb.save

wb.close

end sub

标签: excelvbasumproduct

解决方案


推荐阅读