【发布时间】:2016-02-23 15:54:32
【问题描述】:
我正在尝试在 vba 中使用 Sumproduct 函数。 首先我尝试了这个:
sht.Cells(LastRowsht + 1, 6) = Application.SUMPRODUCT((Transaction = "Vente") * (TickerD2 = sht.Cells(LastRowsht + 1, 2)), ValeurFlux))
其中 Transaction、TickerD2 和 ValeurFlux 是相同长度的范围。(它是一整列)。 我在许多论坛上看到,当有标准时,vba 中的 sumproduct 是有问题的。
人们建议使用 .Evaluate
sht.Cells(LastRowsht + 1, 6) = Application.Evaluate("SOMMEPROD((Transaction = "Vente") * (TickerD2 = sht.Cells(LastRowsht + 1, 2)), ValeurFlux)")
但它给出了名字。 我使用 SOMMEPROD 因为我的 Excel 是法语的,所以我想我需要翻译。 我认为公式中存在拼写错误,但我不熟悉评估。
谢谢。
这是我在 excel 中使用的公式,它有效! 我不知道为什么在 vba 中它不能
=SOMMEPROD((Data2!D:D="Achat")*(Data2!C:C=B8);Data2!I:I)
【问题讨论】: