title: Unable to Hide a column in Excel 97-2003 workbook
body: <p>I am trying to hide a column A1 in my sheet using vba. But am getting a error <strong>"unable to set hidden property of range class"</strong></p>
  
  <p>Here is my code:</p>
  
  <pre><code>  ActiveWorkbook.Sheets("Project").Activate
     ActiveSheet.Unprotect password
  
     Dim cmt As comment
     Dim iRow As Integer
  
     For iRow = 1 To Application.WorksheetFunction.CountA(Columns(1))
        Set cmt = Cells(iRow, 1).comment
           If Not cmt Is Nothing Then
  
              Cells(iRow + 1, 1) = Cells(iRow, 1).comment.Text
              Cells(iRow, 1).comment.Delete
           Else
           MsgBox "No Comments"
           End If
     Next iRow
  
     MsgBox ActiveSheet.ProtectionMode
  
     ActiveSheet.Columns(1).Select
  
     Selection.EntireColumn.Hidden = True
  </code></pre>
  
  <p>Am getting error in the line</p>
  
  <pre><code>Selection.EntireColumn.Hidden = True
  </code></pre>
  
  <p>I have included <strong>MsgBox</strong> to check whether the sheet is protected and is there any comment available in the cells of that column. </p>
  
  <p><strong>1st MsgBox returns as No Comments and 2nd returns as false.</strong></p>
  
  <p>So the sheet is not protected and comment is also not present.</p>
  
  <p>Confused on why getting the error eventhough.</p>
  
  <p>Please help me out</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I have changed my code like this:</p>
  
  <pre><code> ActiveWorkbook.Sheets("Project").Activate
  
      Dim sh As Shape
      Dim rangeToTest As Range
      Dim lRow As Long
      Dim c As Range
  
      lRow = ActiveSheet.Range("A" &amp; ActiveSheet.Rows.Count).End(xlUp).Row
  
      Set rangeToTest = ActiveSheet.Range("A1:A" &amp; lRow)
          For Each c In rangeToTest
  
              For Each sh In ActiveSheet.Shapes
                  sh.Delete
              Next sh
          Next c
  
      ActiveSheet.Range("A1").EntireColumn.Hidden = True
  </code></pre>
  
  <p>And it worked. But I have added comments to other column headers which i get on hovering mouse over the cell. Am not getting the comments now..</p>
  
  <p>Does deleting shapes have something to do with comments?</p>