Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function CONTARCOLOR(CeldaColor As String, RangoSuma As String) As Double
- 'Ej CONTARCOLOR("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 contamos sus coincidencias
- Dim oRango As Object
- Dim oCelda As Double
- Dim c As Integer
- Dim f As Integer
- Dim oCuenta as Integer
- 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 + 1
- End If
- Next
- Next
- CONTARCOLOR = oCuenta
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement