Add In
단축키로 색 넣기
캐스트
2009. 9. 18. 17:11
단축키로 선택한 셀에 대해 색을 넣을 수 있도록 한 추가기능입니다.
업무를 하다 보면 자료를 비교하게 되는 경우가 많이 생깁니다.
자료를 비교하는 방법에는 여러가지가 있을 수 있지만 가장 간단히 할 수 있는 것이 체크한 자료에 색을 칠해서 구분하는 것입니다.
해당파일을 추가기능으로 하면 단축키 Alt + C 를 눌렀을때 선택한 셀에 노란색을 칠합니다.
마우스를 왔다갔다 움직이지 않고서 셀에 색을 지정할 수 있어 아주 유용하게 사용할 수 있습니다.
그리고 반전 기능도 있어서 노란색이 지정된 셀에서 다시 단축키를 누르면 색없음으로 바뀝니다.
색이 없는 셀과 노란색이 지정된 셀을 함께 선택후 단축키를 누르면 전체가 반전되는 것이 아니라 전부 노란색으로 지정되게 됩니다.
색이 없는 부분은 노란색으로, 노란색부분은 색이 없게끔 하는 것도 생각해봤지만 전자의 방식이 더 유용하다고 생각되어 이렇게 설정했습니다.
추가기능 파일은 2003버전에서도 작동합니다.
다음 버전에서는 색을 설정하여 쓸 수 있도록 하는 방법, 반전기능의 선택여부설정등에 대해 생각해보겠습니다.
'이 부분은 워크북개체 안에 넣어줍니다.
'단축키설정
Private Sub Workbook_Open()
With Application
.OnKey "%c", "Coloring_Yellow"
End With
End Sub
'단축키설정
Private Sub Workbook_Open()
With Application
.OnKey "%c", "Coloring_Yellow"
End With
End Sub
'이 부분은 모듈안에 넣어줍니다.
'선택셀에 노랑색을 칠하고 만약 칠해져 있을 경우 색을 지운다.
Sub Coloring_Yellow() ' 노란색
On Error Resume Next
Dim cel As Range
Dim chk As Integer
If Selection.Count = 1 Then
If ActiveCell.Interior.Color = 65535 Then
With ActiveCell.Interior
.Pattern = xlNone
End With
Else
With ActiveCell.Interior
.Pattern = xlSolid
.Color = 65535
End With
End If
Else
For Each cel In Selection.SpecialCells(xlCellTypeVisible)
If cel.Interior.Color = 65535 Then
chk = chk + 1
Else
Exit For
End If
Next cel
If chk = Selection.SpecialCells(xlCellTypeVisible).Count Then
Selection.SpecialCells(xlCellTypeVisible).Interior.Pattern = xlNone
Else
Selection.SpecialCells(xlCellTypeVisible).Interior.Color = 65535
End If
End If
End Sub
'선택셀에 노랑색을 칠하고 만약 칠해져 있을 경우 색을 지운다.
Sub Coloring_Yellow() ' 노란색
On Error Resume Next
Dim cel As Range
Dim chk As Integer
If Selection.Count = 1 Then
If ActiveCell.Interior.Color = 65535 Then
With ActiveCell.Interior
.Pattern = xlNone
End With
Else
With ActiveCell.Interior
.Pattern = xlSolid
.Color = 65535
End With
End If
Else
For Each cel In Selection.SpecialCells(xlCellTypeVisible)
If cel.Interior.Color = 65535 Then
chk = chk + 1
Else
Exit For
End If
Next cel
If chk = Selection.SpecialCells(xlCellTypeVisible).Count Then
Selection.SpecialCells(xlCellTypeVisible).Interior.Pattern = xlNone
Else
Selection.SpecialCells(xlCellTypeVisible).Interior.Color = 65535
End If
End If
End Sub