[vba] 조건부 서식이 걸린 셀 Display 색상 가져오기 > vb6.0/vba

본문 바로가기

vb6.0/vba

[vba] [vba] 조건부 서식이 걸린 셀 Display 색상 가져오기

회원사진
하나를하더라도최선을
2020-09-08 01:43 4,909 0

본문



조건부 서식이 걸린 셀의 색상을 카운트할 수 있습니다.

아래처럼 [알고자 하는 셀].DisplayFormat.Interior.Color로 조건부 서식으로 지정한 셀 색상 값을 가져올 수 있습니다.

dColor = rasCell.DisplayFormat.Interior.Color

5a71c8e4fb5c7a16cbdf603ed4d735fc_1599496965_1778.png
 

Function Color(intRng As Range) As String
    Dim rasCell As Range
    Dim Y As Integer
    Dim R As Integer
    Dim G As Integer
    Dim dColor As Long
    For Each rasCell In intRng
        If rasCell.FormatConditions.Count > 0 Then
            dColor = rasCell.DisplayFormat.Interior.Color
            If dColor = RGB(2552550Then
                Y = Y + 1
            ElseIf dColor = RGB(25500Then
                R = R + 1
            ElseIf dColor = RGB(8413053Then
                G = G + 1
            End If
        End If
    Next
    Color = Y & R & G
End Function



댓글목록0

등록된 댓글이 없습니다.
게시판 전체검색