본문 바로가기

VBA/Code

[VBA] ColorCount

반응형

Basic 파일 다운로드

ColorCount.bas
0.00MB

 

함수 사용방법

VBA Code

Function ColorCount(countRange As range, colorRange As range, Optional colorType As Boolean = False) As Long
    Application.Volatile True
    On Error Resume Next
    Dim rng As range, result As Double
    If colorType Then
        For Each rng In countRange
            If rng.Font.Color = colorRange.Font.Color Then result = result + 1
        Next rng
    Else
        For Each rng In countRange
            If rng.Interior.Color = colorRange.Interior.Color Then result = result + 1
        Next rng
    End If
    ColorCount = result
End Function

 

유사 함수

반응형