Advertisement
Guest User

Untitled

a guest
Mar 18th, 2020
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. Public Function CONTARCOLOR( RangoSuma As String,CeldaColor As String) As Double
  2.  
  3. 'Ej CONTARCOLOR("B5";"E2:F42") '' No olvidar las comillas ,
  4. 'el primer parametro es la celda donde esta el color, la segunda es el rango
  5. ' donde procesamos y contamos sus coincidencias
  6.  
  7. Dim oRango As Object
  8. Dim oCelda As Double
  9. Dim c As Integer
  10. Dim f As Integer
  11. Dim oCuenta as Integer
  12. oCuenta=0 'inicializamos variable
  13. oRango = ThisComponent.CurrentController.ActiveSheet
  14. oCelda = oRango.GetCellRangeByName(CeldaColor).CellBackColor
  15. oRango = oRango.GetCellRangeByName(RangoSuma)
  16. For c = 0 to oRango.Columns.Count - 1
  17. For f = 0 to oRango.Rows.Count - 1
  18. If oRango.GetCellByPosition(c,f).CellBackColor = oCelda Then
  19. oCuenta = oCuenta + 1
  20. End If
  21. Next
  22. Next
  23. CONTARCOLOR = oCuenta
  24.  
  25. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement