땡큐엑셀vba & 엑셀매크로

 

 

 

 

 

 

 

 

'CurrentRegion,Interior.Color,Find,FindNext
'찾기


'Sheet1의 코드번호와 일치하는 값을 Sheet2에서 찾고 해당 바탕색으로 칠하기

'
'source by 땡큐엑셀vba & 엑셀매크로
'
Sub 같은값찾아바탕색칠하기()
    Dim 범위 As Range
    Dim Rng As Range
    
    
    
    
    마지막행 = Cells(Rows.Count, "A").End(xlUp).Row
    Set 범위 = Sheets("Sheet2").Range("A1").CurrentRegion
    
    '2행부터 마지막행까지 루프
    For i = 2 To 마지막행
        찾을값 = Cells(i, "A")
        바탕색 = Cells(i, "B").Interior.Color
        
        
         '1.검색
         Set Rng = 범위.Find(what:=찾을값, lookat:=xlWhole)
    
        
         If Not Rng Is Nothing Then '검색결과가 있다면
            strAddr = Rng.Address  '첫 위치 주소
            
            '2.검색결과가 없을때 까지 루프
            Do
                '찾은셀에 바탕색칠하기
                Rng.Interior.Color = 바탕색
                
                Set Rng = 범위.FindNext(Rng) '다음값으로
            Loop While Not Rng Is Nothing And Rng.Address <> strAddr
         End If

    Next i
    

    MsgBox "완료되었습니다", vbInformation, "땡큐엑셀vba & 엑셀매크로"

End Sub

 

 

같은값찾아 바탕색찰하기-CurrentRegion,Interior.Color,Find,FindNext-땡큐엑셀vba.xlsm
0.05MB