title: Enable Drop Down Macro for Protected Sheet
body: <p>I have created a macro that allows a user to select an option from a dropdown list which unhides selected rows that corresponds with their selection. The problem is when I protect the sheet I get the following error &quot;Run-time error '1004'&quot; when I select an option for the drop down list. I need this sheet to be protected so the user cannot touch the data sets shown. Here is a sample code (original version is very long):</p>
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  ActiveSheet.Activate
  If Not Application.Intersect(Range(&quot;C15&quot;), Range(Target.Address)) Is Nothing Then
  Select Case Target.Value
  Case Is =&quot;Option 1&quot;
  Rows(&quot;17:75&quot;).EntireRow.Hidden = True
  Case Is =&quot;Option 2&quot;
  Rows(&quot;17:28&quot;).EntireRow.Hidden = False
  End Select
  End If
  End Sub
  </code></pre>
  <p>I've been reading other threads and I've come across a few options that said I need to Unprotect and Protect my sheet but I'm not to sure how to add this to the code above. And if this is the best option for what I am trying to accomplish</p>
  <p>Option 1</p>
  <pre><code>Sub UnprotectAll()
      Dim sh As Worksheet
      For Each sh In ActiveWorkbook.Worksheets
          sh.Unprotect Password:=yourPassword
      Next sh
  End Sub
  
  Sub ProtectAll()
      Dim sh As Worksheet
      For Each sh In ActiveWorkbook.Worksheets
          sh.Protect Password:=yourPassword
      Next sh
  End Sub
  </code></pre>
  <p>Option 2 - Adding this code somewhere below</p>
  <pre><code>UserInterFaceOnly:=True
  </code></pre>
  <p>Any suggestions in how I can accomplish this? And what the full code would look like?</p>
  <p>Thanks so much!</p>