title: Excel - Run-time error '1004': Unable to set the hidden property of the range class
body: <p>I am new to scripting and I am trying to improve a existing Macro. I recorded a macro to remove duplicate and added it in a Main function which calls some other functions, but I am getting this error when I add the macro I recorded:</p>
  
  <pre><code>Run-time error '1004': Unable to set the hidden property of the range class
  </code></pre>
  
  <p>The code looks like</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
      Dim changed As Range
      Set changed = Intersect(Target, Range("J15"))
      If Not changed Is Nothing Then
          Range("A48:A136").EntireRow.Hidden = True
          Select Case Target.Value
              Case "Agriculture"
                  Range("A48:A96").EntireRow.Hidden = False
              Case "Commercial"
                  Range("A97:A136").EntireRow.Hidden = False
              Case "MDP"
                  Range("A48:A61").EntireRow.Hidden = False
          End Select
          Range("J15").Select
      End If
  End Sub
  </code></pre>