need help with sumproduct formula in vba

star64

New Member
Joined
Jun 8, 2011
Messages
5
I have some help on formula syntax for sumproduct

Below is my code:

Dim m As Integer
Dim k As Integer
Dim Rng1 As Range
Dim Rng2 As Range
Dim Rng3 As Range

Set Rng1 = Range(Cells(row + 1, 2), Cells(row + m, 2))
Set Rng2 = Range(Cells(row + 1, 5), Cells(row + m, 5))
Set Rng3 = Range(Cells(row + 1, 5), Cells(row + k, 5))

Range("F17").Select
ActiveCell.Formula = "=$B$17+SumProduct(Rng1.Address,Rng2.Address)"

'Rng1 = $B$18:$B$23
'Rng2 = $E$18:$E$23

I want to show the formula of SumProduct on Excel Cell"F17"
like this "$B$17+SumProduct($B$18:$B$23,$E$18:$E$23)" but the syntax in BLUE does not work

The range cannot be fixed in the syntax because they are flexible.

Is there any suggestions for the syntax inside SumProduct?

Thank you very much for your time
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try...

Code:
ActiveCell.Formula = "=$B$17+SUMPRODUCT(" & Rng1.Address & "," & Rng2.Address & ")"

By the way, it doesn't look like the variable 'row' has been declared or assigned a value. And, while 'm' and 'k' have been declared, it doesn't look like they've been assigned a value either.
 
Upvote 0
Thank you very much Domenic :)

Your syntax works!!

For your mention, The syntax I posted are some of my code that I have a problem with. I have already declared and assigned value for all of them.

Again, thank you very much for your help. I really appreciate it :).
I have been trying to figure out this problem for half of my day.
 
Upvote 0
You're very welcome! Glad I could help! And thanks for the feedback!
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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