1. FAQ
  2. 엑셀(Excel)
  3. AfterEffects
  4. Premiere
  5. Photoshop
  6. ETC

이 게시판은 아별닷컴 회원만 질문을 올릴 수 있습니다. 회원에게 주어지는 특권인셈이지요. 회원이 아닌 분들은 열람만 가능합니다.

 

 저번에 덧글이 많은 도움이 되었습니다. 정말 감사합니다. 이번에는 셀의 서식에서 채우기색에 관한 것인데요. 이미 아시겠지만 다음을 보시면,

 

 Sub Macro1()

With Range("W45")
 .Interior.ColorIndex = Range("I24").Interior.ColorIndex
 End With
 
End Sub

 

 다른 셀에 있는 색을 가져올 수가 있는데요, 조건부 서식으로 색을 지정한 셀들의 색들은 어떻게 가져와야 할지 모르겠습니다.  그럼 부탁드리고 Happy New Year~~~


댓글 '1'

profile

[레벨:30]아별

2009.12.31 00:21:21
*.130.73.75

안녕하세요?

조건부 서식에서 지정한 셀 색상을 갖고 오고 싶으시군요..

예전에 엑사모 같은데서 비슷한 질문을 본적이 있는데.. 다 못 갖고온다는 답변뿐이었습니다.

 

조건부 서식에서 값으로 조건을 걸었을 경우에는 갖고 올 수가 있는데요..

수식으로 조건을 걸었을때는.. 수식을 어떻게 평가해야할지에 대한 적당한 해법이 없네요..

홀수열에 음영을 넣는 "=MOD(ROW(),2)" 이런 조건이나 조건에 이름을 사용하거나 했을때..

수식으로 조건을 거는 방법은 무궁무진한지라.. 접근이 어렵습니다.

 

 

값으로 조건을 걸었을때 셀색상을 갖고 오는 사용자 정의함수를 만들어봤습니다.

조건부서식이 없거나, 조건을 만족하지 못 할 경우에는 기본 셀 음영색을 갖고 옵니다.

수식으로 된 조건에 해당하면.. "에라"죠.. =_=;;

참고하세요.

 

abyul_20091231_FormatConditions_colorIndex.xls

 

 Option Explicit

Function getConditionalColor(uRange As Range)
    Dim i As Integer
    Dim cntConditions As Integer
    cntConditions = uRange.FormatConditions.Count
    If cntConditions < 1 Then
        getConditionalColor = uRange.Interior.ColorIndex
    Else
        For i = 1 To cntConditions
            With uRange.FormatConditions(i)
                Select Case .Type
                Case xlCellValue
                    Select Case .Operator
                        Case xlBetween
                            If uRange.Value >= .Formula1 And uRange.Value <= .Formula2 Then
                                getConditionalColor = .Interior.ColorIndex
                                Exit Function
                            End If
                        Case xlEqual
                            If uRange.Value = .Formula1 Then
                                getConditionalColor = .Interior.ColorIndex
                                Exit Function
                            End If
                        Case xlGreater
                            If uRange.Value > .Formula1 Then
                                getConditionalColor = .Interior.ColorIndex
                                Exit Function
                            End If
                        Case xlGreaterEqual
                            If uRange.Value > .Formula1 Then
                                getConditionalColor = .Interior.ColorIndex
                                Exit Function
                            End If
                        Case xlLess
                            If uRange.Value < .Formula1 Then
                                getConditionalColor = .Interior.ColorIndex
                                Exit Function
                            End If
                        Case xlLessEqual
                            If uRange.Value <= .Formula1 Then
                                getConditionalColor = .Interior.ColorIndex
                                Exit Function
                            End If
                        Case xlNotBetween
                            If uRange.Value <= .Formula1 Or uRange.Value >= .Formula2 Then
                                getConditionalColor = .Interior.ColorIndex
                                Exit Function
                            End If
                        Case xlNotEqual
                            If uRange.Value <> .Formula1 Then
                                getConditionalColor = .Interior.ColorIndex
                                Exit Function
                            End If
                    End Select
                Case xlExpression
                        getConditionalColor = "수식조건평가못함"
                End Select
            End With
        Next i
    End If
    If IsEmpty(getConditionalColor) Then
        getConditionalColor = uRange.Interior.ColorIndex
    End If
End Function


첨부
문서 첨부 제한 : 0Byte/ 2.00MB
파일 제한 크기 : 2.00MB (허용 확장자 : *.*)
List of Articles
번호 제목 글쓴이 날짜sort 조회 수
공지 공지 [공지] 아별닷컴의 엑셀 질문방 폐쇄합니다. 카페 질문방 이용하세요.. imagefile [레벨:30]아별 2015-04-23 43035