sumproduct in code

P

papa jonah

I am using code to try and populate a table.

The table looks like

AA AB
1
2 1
3 2

I am using code to put a sumproduct in AB2 and AB3 (and further as
necessary).

Currently the line of code I am using is:
cells (r+1, "ab").formula = "=sumproduct((" & causecats.address & "=" &
_
cells(r+1, "aa") & ")*(" & cause.columns(3).address & "))"

When I look at what is showing up in cell AB2, I see:
=sumproduct(($ah$2:$ah$32=1)*($ak$2:$ak$32))

The ranges are correct. The problem appears to be that the value, 1,
in the first array must be in quotes in order to achieve the proper
result.

How do I change my code so that the necessary quotes are included?

Thanks
Papa J
 
B

Bernie Deitrick

Papa J,

Cells(r + 1, "ab").Formula = "=sumproduct((" & _
causecats.Address & "=""" & _
Cells(r + 1, "aa") & """)*(" & _
cause.Columns(3).Address & "))"

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top