0

What is the correct syntax for sum product?

Here is my code:

mFormula = "=SUMPRODUCT(--((1.Insert_Data!F:F)=2.Counting_sheet!A8)),(--((1.Insert_Data!E:E)))"
Range("C8") = Evaluate(mFormula)

3 Answers3

1

Your parentheses are not balanced

mFormula = "=SUMPRODUCT(  --(('1.Insert_Data'!F:F)='2.Counting_Sheet'!A8), " & _
                         "--('1.Insert_Data'!E:E)  )"

Range("C8") = Evaluate(mFormula)
Tim Williams
  • 154,628
  • 8
  • 97
  • 125
  • If you use the same formula in a worksheet cell does it work? Is the workbook containing those sheets active? – Tim Williams Nov 02 '20 at 02:06
  • Dim e As Integer Dim v As Integer Dim mFormula As String For e = 8 To 120 mFormula = "=SUMPRODUCT( --(('1.Insert_Data'!F:F) = '2.Counting_sheet'!A&e), " & _ "'1.Insert_Data'!E:E)" Range("C" & e) = Evaluate(mFormula) Next e Still did not work instead gave me a name error – Vincent Vuong Nov 03 '20 at 04:17
0
mFormula = "=SUMPRODUCT(  --(('1.Insert_Data'!F:F) = '2.Counting_sheet'!A8), " & _
                     "'1.Insert_Data'!E:E)"

this is the correct syntax

0

Sub itemno() '

' Dim e As Integer Dim mFormula As String

For e = 8 To 120

mFormula = "=SUMPRODUCT(  --(('1.Insert_Data'!F:F) = '2.Counting_sheet'!A" & e & ")," & _
                     "'1.Insert_Data'!E:E)"
                     
                     
Range("C" & e).Value = mFormula

Next e

End Sub