G
ghobbit
Hi
I have two columns on which I want to run a sumproduct formula using
VBA. Column D has names and column O has what I want to match it with.
I have two cells containing the information for the criteria namely Q3
= John and S1 = AGREE. I would like the result put into S2
I want to run this using a command button rather than have the formula
in the cell.
If I put this formula into the cell S2 then it works fine
=SUMPRODUCT((D22500=Q3)*(O2:O2500=S1))
However if I create a button and have this code, I get a #Value error
in S3 instead of the result
Private Sub CommandButton2_Click()
Cells(3, "S").value =
Evaluate("=SUMPRODUCT((D22500=Q3)*(O2:02500=S1))")
End Sub
If I leave out the evaluate and just have
Cells(3, "S").value =SUMPRODUCT((D22500=Q3)*(O2:02500=S1))
then I get a syntax error
Is there anything obvious I'm doing wrong??
many thanks
Steve
I have two columns on which I want to run a sumproduct formula using
VBA. Column D has names and column O has what I want to match it with.
I have two cells containing the information for the criteria namely Q3
= John and S1 = AGREE. I would like the result put into S2
I want to run this using a command button rather than have the formula
in the cell.
If I put this formula into the cell S2 then it works fine
=SUMPRODUCT((D22500=Q3)*(O2:O2500=S1))
However if I create a button and have this code, I get a #Value error
in S3 instead of the result
Private Sub CommandButton2_Click()
Cells(3, "S").value =
Evaluate("=SUMPRODUCT((D22500=Q3)*(O2:02500=S1))")
End Sub
If I leave out the evaluate and just have
Cells(3, "S").value =SUMPRODUCT((D22500=Q3)*(O2:02500=S1))
then I get a syntax error
Is there anything obvious I'm doing wrong??
many thanks
Steve