셀을 보호하지만 드롭다운 목록이 작동하도록 허용

셀을 보호하지만 드롭다운 목록이 작동하도록 허용

드롭다운 목록이 있는 셀을 보호하고 싶지만 여전히 드롭다운 목록이 작동하기를 원합니다.

보호하려고 하면 사용자가 드롭다운 목록을 사용하여 다른 항목이나 매크로를 선택할 수 없습니다.

이 오류 메시지가 나타납니다.

"변경하려는 셀 또는 차트는 보호되어 있으므로 읽기 전용입니다. 보호된 셀 또는 차트를 수정하려면 먼저 보호되지 않은 시트 명령(검토 탭, 변경 그룹)을 사용하여 보호를 제거하십시오. 비밀번호를 묻는 메시지가 나타날 수 있습니다. ."

답변1

드롭다운이 셀에 첨부됩니다. 여기에 데이터가 저장됩니다. 유효성 검사를 통해 데이터의 유효성이 보장됩니다.

아직 확인하지 않았다면 셀이 잠겨 있지 않은지 확인하세요. 셀을 마우스 오른쪽 버튼으로 클릭하고 셀 서식을 클릭한 다음 보호 탭으로 이동합니다. 잠김 확인란을 선택 취소해야 합니다.

답변2

이 질문이 잘못 해석되었을 수도 있다고 생각합니다. 그렇다면, 그리고 내가 올바르게 해석했다면 여기에 해결책이 있습니다.

Excel에서는 실제로 스프레드시트 사용자가 유효성 검사 목록을 사용하는 셀을 덮어쓸 수 있도록 허용합니다. 목록에 "사과", "복숭아" 및 "오렌지" 값이 포함된 경우 표준 작업을 통해 사용자는 셀에 첨부된 유효성 검사 목록이 없는 것처럼 보호되지 않은 셀에 "브로콜리"를 입력할 수 있습니다. 그러나 셀과 워크시트를 보호하면 유효성 검사 목록에서 항목을 선택하는 기능이 비활성화되어 문제가 될 수 있습니다.

이것이 문제인 경우 해결책은 다음과 같습니다.

1.  Format the cell using the validation list so it's 
    unprotected. 
2.  With the cursor positioned at that cell, open the 
    Validation menu origintally used to identify the validation 
    list. 
3.  On the Settings tab of the Data Validation window pane,
    be sure that "ignore blank" is unchecked, and 
    continue to leave that window pane open. 
4.  On the "Error alert" tab of the Data Validation window
    pane:  
      a) Be sure "Show error alert after invalid data is
         entered" is checked. 
      b) Select "Stop" under the "Style" heading.
      c) Give your error alert a name under "Title"; this 
         can be anything, but a short title is best. 
      d) Under "Error message", type a short message that you
         want to appear if a user tries to manually type a value
         in the cell - something like "Please use the drop-down
         menu provided to select a value for this cell."
      e) Click "OK". 

이렇게 하면 워크시트가 보호되지 않은 경우에도 사람들이 데이터 유효성 검사를 사용하려는 셀에 원하는 내용을 입력하는 것을 차단할 수 있습니다. 그럼에도 불구하고 데이터 유효성 검사 목록 자체가 의도하지 않게 업데이트되는 것을 방지하기 위해 워크시트를 보호할 수 있습니다.

답변3

내 컴퓨터(Excel 2010을 실행하는 PC)에서는 실제로 드롭다운 목록 자체가 바로 오른쪽 셀에 연결된 것처럼 보입니다. 따라서 A7에 드롭다운 목록을 추가하려면 A7과 B7을 모두 잠금 해제해야 합니다.

이는 버그일 수 있지만 비교적 간단한 수정입니다.

답변4

보호된 시트에서:

통합 문서에 아래 링크 붙여넣기

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

    Dim wsh As Variant
    For Each wsh In Worksheets(Array("Sheet1"))
        wsh.EnableOutlining = True
        wsh.Protect UserInterfaceOnly:=True, Password:="", _
            DrawingObjects:=False, _
    Contents:=True, _
    Scenarios:=True, _
    AllowFormattingCells:=False, _
    AllowFormattingColumns:=False, _
    AllowFormattingRows:=False, _
    AllowInsertingColumns:=False, _
    AllowInsertingRows:=False, _
    AllowInsertingHyperlinks:=False, _
    AllowDeletingColumns:=False, _
    AllowDeletingRows:=False, _
    AllowSorting:=False, _
    AllowFiltering:=False, _
    AllowUsingPivotTables:=False
    Next wsh

Dim Oldvalue As String
Dim Newvalue As String

On Error GoTo Exitsub
If Target.Address = "$C$2" Then 'As required
    If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
    GoTo Exitsub
    Else: If Target.Value = "" Then GoTo Exitsub Else
        Application.EnableEvents = False
        Newvalue = Target.Value
        Application.Undo
        Oldvalue = Target.Value
        If Oldvalue = "" Then
            Target.Value = Newvalue
        Else
            Target.Value = Oldvalue & ", " & Newvalue
        End If
    End If
End If


Exitsub:
Application.EnableEvents = True

End Sub

관련 정보