Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't make Dsum to work in VBA

Status
Not open for further replies.

Manuel10

Programmer
Nov 12, 2004
18
NL
Hello,
I found very helpsome tips by searching in this forum and came across the use of Excel functions like Dsum and SumProduct for applying multiple conditions. However I can't get these functions to work (properly) in VBA.

In the example code the syntax of the code between the brackets after SumProduct is not correct. I have tried several variants, but couldn't find the solution.
Can anyone help me with the correct notation?

Set myRange1 = ActiveWorkbook.Worksheets("Blad1").Range("A1:A5")
Set myRange2 = ActiveWorkbook.Worksheets("Blad1").Range("C1:C5")
Set myRange3 = ActiveWorkbook.Worksheets("Blad1").Range("D1:D5")

Sum = Application.WorksheetFunction.SumProduct((myRange1 = "Text1") * (myRange2 = "Text2") * myRange3)
 
Sorry,
The title of this mail should have been: "Can't make SumProduct to work in VBA".
 
Sorry,
The title of this mail should have been: "Can't make SumProduct to work in VBA".

Manuel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top