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
Dim acumulado 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
filados = rango_2.Row
columnados = rango_2.Column
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
For m = filados To filados + filasdos - 1
For n = columnados To columnados + columnasdos - 1
valordos = Cells(m, n).Value
multiplicacion = (valoruno * valordos)
acumulado = acumulado + multiplicacion.Value
Next n
Next m
Next j
Next i
SUMAPRODUCTO_SI = acumulado
End Function
Please, If someone can help me...¡thank you!
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
Dim acumulado 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
filados = rango_2.Row
columnados = rango_2.Column
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
For m = filados To filados + filasdos - 1
For n = columnados To columnados + columnasdos - 1
valordos = Cells(m, n).Value
multiplicacion = (valoruno * valordos)
acumulado = acumulado + multiplicacion.Value
Next n
Next m
Next j
Next i
SUMAPRODUCTO_SI = acumulado
End Function
Please, If someone can help me...¡thank you!