title: EntireColumn.Hidden in Worksheet_Change()
body: <p>Using Excel 2010 I am editing an existing unprotected workbook and have created <code>EntireColumn.Hidden</code> and <code>EntireRow.Hidden</code> in commands in the <code>Worksheet_Change()</code> event to fire when a Data Validation cell is changed, but they don't work.</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  
  With Application
      .ScreenUpdating = False
      .EnableEvents = False
  End With
  
  If Not Intersect(Target, Range("$C$2")) Is Nothing Then
      Select Case Target.Value
          Case "NO"
              MsgBox "You just changed to HIDE"          '&lt;= Proves it fires
              Range("$C$3").Value = "Invisible"          '&lt;= Does change cell
              Columns("N:O").EntireColumn.Hidden = True  '&lt;= Doesn't hide
          Case "YES"
              MsgBox "You just changed to UNHIDE"        '&lt;= Proves it fires
              Range("$C$3").Value = "Visible"            '&lt;= Does change cell
              Columns("N:O").EntireColumn.Hidden = False '&lt;= Doesn't unhide
      End Select
  End If
  
  With Application
      .ScreenUpdating = True
      .EnableEvents = True
  End With
  
  End Sub
  </code></pre>
  
  <p>The event is firing as I have <code>MsgBox</code>es to prove it. I can change cell values etc., but not the hiding/unhiding of the column/row.</p>
  
  <p>I've copied my code to a new book and it works. So I copied it back into the original book but as a fresh, blank sheet and it works. It still doesn't work in the original, sizable sheet.</p>
  
  <p>When I copied this into a simple macro it <strong>does</strong> work as required, hiding the correct columns, but at the push of a button:</p>
  
  <pre><code>Sub HideThem()
      Columns("N:O").EntireColumn.Hidden = True '&lt;= DOES work
  End Sub
  </code></pre>
  
  <p>I need this to update automatically based on the value of a single cell. I've even tried to call this mini <code>Sub</code> from within the <code>Worksheet_Change()</code> event but that didn't work either.</p>
  
  <p>Are there any known conflicts with other commands/events, on-sheet buttons, images, merged cells etc. that could be preventing the columns/rows from hiding?</p>
  
  <p>I tried to use a <code>CheckBox</code> instead of a <code>YES/NO</code> Data Validation cell to fire the code (as that could be acceptable) but when I try to insert an ActiveX <code>CheckBox</code> it says <em>Cannot insert object</em>, even in a brand new blank book. Could this be a related problem?</p>