How to use sumproduct in VBA?

ZionX

New Member
Joined
Mar 17, 2011
Messages
11
Good days, can anyone help me on the sumproduct in vba?
below is the code i wrote but not working, and return #VALUE!:
Code:
Set rng01 = Range("K4")

p = Cells(1, 1).Value
IC01 = Range("A12").CurrentRegion.Rows.count

For count01 = 12 To 300
Set rng02 = Range(Cells(p, count01), Cells(IC01, count01))

Cells(1, count01) = Application.SumProduct(rng01, rng02)

Next count01

Thanks for help and assist.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi Zionx,

First you need to be sure you have the same dimensions in arrays that will be arguments, see these remarks in function help.

Remarks:

  • The array arguments must have the same dimensions. If they do not, SUMPRODUCT returns the #VALUE! error value.
  • SUMPRODUCT treats array entries that are not numeric as if they were zeros.
http://office.microsoft.com/en-us/e...ion-HP010342935.aspx?CTT=5&origin=HA010342655

If you continue with some problems please show sample of your sheet.

Hope this helps,

Regards.
 
Upvote 0
It's a little trickier if you want to use the (string = range1)* range2 variation. Here is the syntax:

Code:
Worksheets("Sheet1").Cells(i, j + 2) = Evaluate("SUMPRODUCT(--(range1=$B" & i & ")*(range2=" & j & ")*range3)")

the "i" and "j" are the variables in a double loop.

I think thats enough to keep you going. If you have a hard time making it work post your code here and we can test it.
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,484
Members
452,917
Latest member
MrsMSalt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top