# Create a sumproduct function in vba

#### EliSilver

##### New Member
Hello, I need to make a sumproduct_if function in vba, but I really don´t know how to start.

This is what I have:

Function SUMAPRODUCTO_SI(rango_1 As Range, rango_2 As Range, rango_cond As Range, condicion As String) As Double

Dim filauno As Integer, columnauno As Integer, filasuno As Integer, columnasuno As Integer
Dim filados As Integer, columnados As Integer, filasdos As Integer, columnasdos As Integer

Dim valoruno As Double
Dim valordos As Double

Dim multiplicacion As Double

'Encontrar la primera celda del rango uno y del rango dos

filauno = rango_1.Row
columnauno = rango_1.Column
filasuno = rango_1.Rows.Count
columnasuno = rango_1.Columns.Count

filasdos = rango_2.Rows.Count
columnasdos = rango_2.Columns.Count

For i = filauno To filauno + filasuno - 1
For j = columnauno To columnauno + columnasuno - 1
valoruno = Cells(i, j).Value
valordos = Cells(m, n).Value
multiplicacion = (valoruno * valordos)
Next n
Next m
Next j
Next i

End Function

Please, If someone can help me...¡thank you!

### Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use \$ signs: \$V\$2:\$Z\$99 will always point to V2:Z99, even after copying

Replies
1
Views
57
Replies
7
Views
224
Replies
9
Views
91
Replies
3
Views
54
Replies
1
Views
109

1,141,049
Messages
5,703,937
Members
421,321
Latest member
blusky4

### 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.

### Which adblocker are you using?

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

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