
Excel(2003 및 2007)에서는 창에 초점이 맞지 않을 때 선택된 셀, 행 또는 열이 표시되지 않는다는 점이 정말 짜증스럽습니다. 일반적으로 다른 응용 프로그램에서 작업하는 동안 현재 셀이나 행을 참조하고 싶습니다.
초점이 맞지 않을 때 셀/행을 강조 표시하는 해결 방법이나 수정 사항이 있습니까? 셀을 복사(Ctrl+C)할 수 있다는 것은 알고 있지만 매번 그렇게 하기는 좀 번거롭습니다.
답변1
해결 방법이 있다고 생각하지만 실제로는 상황에 따라 다릅니다!
선택 항목이 변경될 때 실행되는 매크로를 생성하여 각 셀의 배경만 변경할 수 있습니다. 셀을 '나가면' 행의 배경 값이 흰색으로 재설정되고 새 행이 선택됩니다.
Visual Basic 창의 Sheet1에 이것을 추가했습니다.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = xlColorIndexNone
ActiveCell.EntireRow.Interior.ColorIndex = 34
End Sub
이 스크린샷은 애플리케이션이 초점을 잃은 동안 촬영되었습니다.
귀찮을 수도 있지만 이 기능을 켜거나 끌 수 있는 버튼을 쉽게 추가할 수 있습니다!
부정적인 점은 다음과 같습니다. 현재 강조 표시가 제거됩니다. 따라서 페이지에 강조 표시(색상 셀)가 있는 경우 이 기능을 사용하지 않는 것이 가장 좋습니다! 또한 강조 표시된 행으로 인쇄될 수도 있습니다!
답변2
다음은 @datatoo의 코드 수정입니다. 현재 채우기 색상이 손실되지 않도록 이전 값을 읽습니다. 또한 텍스트 색상을 변경하여 더욱 눈에 띄게 만듭니다. 코드 편집기(Excel의 Alt-F11)에서 Excel 시트에 추가했습니다.
딸깍 하는 소리여기워크시트 변경 이벤트 생성에 대한 자세한 내용은
'VBA code for Excel to show active cell in worksheet when worksheet is out of focus
Dim wasActive As String
Dim originalFillColor As String
Dim originalTextColor As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Set up colors on load
If wasActive = Empty Then
wasActive = "A1"
originalFillColor = Range(wasActive).Interior.Color
originalTextColor = Range(wasActive).Font.Color
End If
'Reset previous cell to original color values; If statement prevents removal of grid lines by using "0" for clear fill color when white
If originalFillColor = 16777215 Then
Range(wasActive).Interior.ColorIndex = "0"
Range(wasActive).Font.Color = originalTextColor
Else
Range(wasActive).Interior.Color = originalFillColor
Range(wasActive).Font.Color = originalTextColor
End If
'Set new colors and change active cell to highlighted colors (black fill with white text)
originalFillColor = ActiveCell.Interior.Color
originalTextColor = ActiveCell.Font.Color
wasActive = ActiveCell.Address
ActiveCell.Interior.ColorIndex = "1"
ActiveCell.Font.ColorIndex = "2"
End Sub
답변3
필요한 경우 이와 같은 작업을 수행할 수 있습니다. 시트별로 다를 수도 있지만
Dim wasActive As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If wasActive = Empty Then wasActive = "A1"
Range(wasActive).Interior.ColorIndex = "0"
ActiveCell.Interior.ColorIndex = "6"
wasActive = ActiveCell.Address
End Sub
이렇게 하면 활성화되지 않은 셀이 다시 흰색으로 변경되고 활성 셀이 노란색으로 변경됩니다. 창이 활성화되지 않은 경우에도 계속 표시됩니다. 이것이 최선의 방법인지는 확실하지 않지만 작동합니다.
답변4
모양을 사용하여 선택 항목을 강조 표시합니다.
참고: 다른 Excel 창으로 전환하는 경우에만 작동합니다. 해결 방법으로 빈 Excel 창을 열고 다른 응용 프로그램으로 전환하기 전에 이 창으로 전환하여 강조 표시를 유지할 수 있습니다.
이것을 ThisWorkbookcode(시트 코드가 아닌 workBOOK)에 추가하기만 하면 됩니다. 이는 통합 문서의 모든 시트에 적용됩니다.
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
DeleteSelectionHighlight
End Sub
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
DeleteSelectionHighlight
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
On Error Resume Next
Dim shp As Shape
Application.ScreenUpdating = False
Set shp = ActiveSheet.Shapes("SelectionHighlight")
If Err.Number <> 0 Then
Set shp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, 1, 1, 1, 1)
With shp 'Format shape to your preference
.Name = "SelectionHighlight"
.Line.ForeColor.RGB = RGB(226, 0, 0) ' Border color
.Line.Weight = 1.5
.Line.DashStyle = msoLineSolid
.Fill.Visible = msoFalse 'No background
'.Fill.ForeColor.RGB = RGB(0, 153, 0) 'Background color
'.Fill.Transparency = 0.95 'Background transparency
End With
End If
Dim oldZoom As Integer
oldZoom = Wn.Zoom
Wn.Zoom = 100 'Set zoom at 100% to avoid positioning errors
With shp
.Top = Wn.Selection.Top 'Tweak the offset to fit your desired line weight
.Left = Wn.Selection.Left 'Tweak the offset to fit your desired line weight
.Height = Wn.Selection.Height
.Width = Wn.Selection.Width
End With
Wn.Zoom = oldZoom 'Restore previous zoom
Application.ScreenUpdating = True
End Sub
Private Sub DeleteSelectionHighlight()
On Error Resume Next
Dim shp As Shape
Set shp = ActiveSheet.Shapes("SelectionHighlight")
shp.Delete
End Sub
코드를 조정하여 원하는 대로 모양의 형식을 지정할 수도 있습니다.
장점은 다음과 같습니다.
- 정전이 발생하여 Excel이 충돌하더라도 원래 형식이 손실되지 않습니다.
- 활성 시트를 변경하는 다른 통합 문서에서 Ctrl+[를 사용해도 원래 서식이 손실되지 않습니다.
- CTRL+C 솔루션과 비교하여 다른 Excel 창을 변경할 때 강조 표시를 잃지 않습니다.