Function SUMARCOLOR(CeldaColor As String, RangoSuma As String) As Double
\'Ej SUMARCOLOR("B5";"E2:F42") \'\' No olvidar las comillas , el primer parametro es la celda donde esta el color, la segunda es el rango donde procesamos y sumamos si coinciden
Dim oRango As Object
Dim oCelda As Double
Dim c As Integer
Dim f As Integer
Dim oCuenta as DOUBLE
oCuenta=0 \'inicializamos variable
oRango = ThisComponent.CurrentController.ActiveSheet
oCelda = oRango.GetCellRangeByName(CeldaColor).CellBackColor
oRango = oRango.GetCellRangeByName(RangoSuma)
For c = 0 to oRango.Columns.Count - 1
For f = 0 to oRango.Rows.Count - 1
If oRango.GetCellByPosition(c,f).CellBackColor = oCelda Then
oCuenta = oCuenta+ oRango.GetCellByPosition(c,f).value
End If
Next
Next
SUMARCOLOR = oCuenta
End Function