본문 바로가기
프로그램이야기/엑셀

[엑셀 VBA] 엑사남 11강 #selectionChange이벤트

by 제이앨 2022. 6. 23.

[엑셀 VBA] 엑사남 11강 #selectionChange이벤트

늦은 퇴근시간을 앞당기기 위해

공부합니다^^

몇번을 도전하다 실패한 엑셀VBA를

이번에는 초급을 넘어서보려고 합니다.

 

#학습내용(1)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    With Target.Interior
        
        If .ColorIndex = 3 Then
            .ColorIndex = 0
    Else
          .ColorIndex = 3
    End If
    
    End With
    
End Sub

 

#학습내용(2)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Intersect(Target, Range("F7:L26")) Is Nothing Then Exit Sub
    If Target.Count > 1 Then Exit Sub
    
    With Target.Interior
        
        If .ColorIndex = 6 Then
            .ColorIndex = 0
            
        Else
        
            .ColorIndex = 6
    End If
   
    End With
    
End Sub

 

 

출처 : https://youtu.be/RYWWPZkCbVw

 

댓글