0% found this document useful (0 votes)
164 views1 page

Macros Excel Contar Celdas de COLOR

This document contains code for two functions: COLOR_COND and CONT_COL_COND. COLOR_COND takes a cell as input and returns the color of its formatting condition based on evaluating formulas and comparing the cell value to thresholds. CONT_COL_COND takes a colored cell, color and range as input, counts the number of cells in the range that have the same color as the input cell, and returns the count.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
164 views1 page

Macros Excel Contar Celdas de COLOR

This document contains code for two functions: COLOR_COND and CONT_COL_COND. COLOR_COND takes a cell as input and returns the color of its formatting condition based on evaluating formulas and comparing the cell value to thresholds. CONT_COL_COND takes a colored cell, color and range as input, counts the number of cells in the range that have the same color as the input cell, and returns the count.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Function COLOR_COND(celda As Range) As Long

Dim ReglaActiva As Boolean


For i = 1 To celda.FormatConditions.Count
With celda.FormatConditions(i)
If .Type = xlCellValue Then
Select Case .Operator
Case xlBetween: ReglaActiva = celda.Value >=
Evaluate(.Formula1) _
And celda.Value <= Evaluate(.Formula2)
Case xlNotBetween: ReglaActiva = celda.Value <=
Evaluate(.Formula1) _
Or celda.Value >= Evaluate(.Formula2)
Case xlEqual: ReglaActiva = Evaluate(.Formula1) =
celda.Value
Case xlNotEqual: ReglaActiva = Evaluate(.Formula1) <>
celda.Value
Case xlGreater: ReglaActiva = celda.Value >
Evaluate(.Formula1)
Case xlLess: ReglaActiva = celda.Value <
Evaluate(.Formula1)
Case xlGreaterEqual: ReglaActiva = celda.Value >=
Evaluate(.Formula1)
Case xlLessEqual: ReglaActiva = celda.Value <=
Evaluate(.Formula1)
End Select
ElseIf .Type = xlExpression Then
Application.ScreenUpdating = False
celda.Select
ReglaActiva = Evaluate(.Formula1)
Range(ActiveCell.Address).Select
Application.ScreenUpdating = True
End If
If ReglaActiva Then
COLOR_COND = .Interior.color
Exit Function
End If
End With
Next i
End Function
Function CONT_COL_COND(CeldaColor As Range, Rango As Range) As Integer
Dim celda As Range
Dim resultado As Integer
Dim color As Long
color = COLOR_COND(CeldaColor)
For Each celda In Rango.Cells
If COLOR_COND(celda) = color Then
resultado = resultado + 1
End If
Next celda
CONT_COL_COND = resultado
End Function

You might also like