초점이 맞지 않을 때 Excel에서 셀 선택 표시 참조하고 싶습니다. 초점이 맞지 않을

Excel (2003 및 2007)에 창이 초점이 맞지 않을 때 선택된 셀, 행 또는 열이 표시되지 않는 것은 정말 짜증납니다. 다른 응용 프로그램에서 작업하는 동안 일반적으로 현재 셀 또는 행을 참조하고 싶습니다.

초점이 맞지 않을 때 셀 / 행을 강조 표시하는 해결 방법이나 수정이 있습니까? 셀을 복사 할 수 있다는 것을 알고 있지만 (Ctrl + C) 매번 그렇게하는 것이 번거 롭습니다.



답변

해결 방법이 있다고 생각하지만 실제로는 상황에 따라 다릅니다!

선택이 변경 될 때 실행되고 각 셀의 배경을 변경하는 매크로를 만들 수 있습니다. 셀을 ‘나가’면 행의 배경 값을 흰색으로 재설정 한 다음 새 행을 선택합니다.

Visual Basic 창의 내 Sheet1에 이것을 추가했습니다.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Cells.Interior.ColorIndex = xlColorIndexNone
    ActiveCell.EntireRow.Interior.ColorIndex = 34
End Sub

이 스크린 샷은 응용 프로그램에서 포커스를 잃은 동안 촬영되었습니다.

이 작업은 성가 시겠지만이 기능을 켜거나 끌 수있는 버튼을 쉽게 추가 할 수 있습니다!

네거티브는 (내 머리 꼭대기에서 : 현재 강조 표시를 제거합니다. 따라서 페이지에서 강조 표시가있는 경우 (셀 색이 지정된 경우) 이것을 사용하지 않는 것이 가장 좋습니다! 또한 강조 표시된 행으로 인쇄됩니다!

여기에 이미지 설명을 입력하십시오


답변

필요한 경우 이와 같은 작업을 수행 할 수 있습니다. 시트마다 다를 수 있지만

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

이것은 활성화되지 않은 것을 다시 흰색으로 바꾸고 액티브 셀을 노란색으로 바꿉니다. 창이 활성화되지 않은 경우 여전히 표시됩니다. 이것이 최선의 방법인지 확실하지 않지만 작동합니다.


답변

다음은 @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


답변

모양을 사용하여 선택을 강조 표시하십시오.

참고 : 다른 Excel 창으로 전환 할 때만 작동합니다. 이 문제를 해결하려면 빈 Excel 창을 열고이 창으로 전환 한 다음 다른 응용 프로그램으로 전환하여 강조 표시를 유지하십시오.

이것을 ThisWorkbookcode (시트 코드가 아닌 통합 문서)에 추가하십시오. 통합 문서의 모든 시트에서 작동합니다.

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

코드를 조정하여 원하는 모양으로 서식을 지정할 수도 있습니다.

장점은 다음과 같습니다.

  • 당신은 당신의 엑셀 충돌 정전시 원래 형식을 잃지 않습니다
  • 활성 시트를 변경하는 다른 통합 문서에서 CTRL + [를 사용할 때 원래 서식이 손실되지 않습니다
  • CTRL + C 솔루션과 비교하여 다른 Excel 창을 변경할 때 하이라이트를 잃지 않습니다.

답변

Excel 2003에서는 현재 선택된 셀 주소가 왼쪽 상단에 표시됩니다. 셀이 강조 표시되지는 않지만 셀이 중간으로 이동합니다.


답변

이 문제에 대한 영구적 인 해결책 은 없습니다 .

해결 방법 (잠시 동안의 성가신받을 수 있습니다) 그들이 선택하고 색상을 드롭 다시 재 – 선택하는 동안 선택된 셀의 강조 표시를 변경하는 것입니다.

이 코드를 Sheet1 코드 뒤에 넣고 스프레드 시트로 이동하여 일부 셀을 선택하고 다른 셀을 선택한 다음 첫 번째 코드를 다시 선택하여 색상을 삭제하십시오

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim cell As Range

    For Each cell In Target.Cells
        If cell.Interior.Color = RGB(60, 150, 230) Then
            cell.Interior.Pattern = xlNone
        Else
            cell.Interior.Color = RGB(60, 150, 230)
        End If
    Next
End Sub


답변

선택이 변경 될 때 셀 색상을 배치하는 간단한 솔루션

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Selection.Interior.ColorIndex = xlColorIndexNone
    Selection.Interior.Color = RGB(204, 204, 204)
End Sub


초점이 없어 질 때만 셀 색상을 변경 하는 복잡한 솔루션

표준 모듈에서 :

Option Explicit
Public s As Range

시트에서 당신은 그것이 작동하기를 원합니다 :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Set s = Selection
End Sub

에서 ThisWorkbook:

Private Sub Workbook_Deactivate()
    If s Is Nothing Then
        Set s = Selection
        Exit Sub
    End If
    s.Interior.ColorIndex = xlColorIndexNone
    s.Interior.Color = RGB(204, 204, 204)

    ' This is optional formatting to make the cells look more like they're actually selected
    s.Borders.Color = RGB(130, 130, 130)
    s.BorderAround _
    Color:=RGB(30, 130, 37), Weight:=xlThick
End Sub

Private Sub Workbook_Activate()
    If s Is Nothing Then
        Set s = Selection
        Exit Sub
    End If
    s.Interior.ColorIndex = xlColorIndexNone
    s.Borders.ColorIndex = xlColorIndexNone
End Sub



인용 : 간단한 해결책은 @Dave 의 이전 답변 을 기반으로합니다 . 복잡한 솔루션은 특히이 게시물@JohnColeman 의 도움을 받아 여러 출처에서 수집 되었습니다 .