I am trying to hide a column A1 in my sheet using vba. But am getting a error "unable to set hidden property of range class"
Here is my 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
Am getting error in the line
Selection.EntireColumn.Hidden = True
I have included MsgBox to check whether the sheet is protected and is there any comment available in the cells of that column.
1st MsgBox returns as No Comments and 2nd returns as false.
So the sheet is not protected and comment is also not present.
Confused on why getting the error eventhough.
Please help me out
UPDATE:
I have changed my code like this:
 ActiveWorkbook.Sheets("Project").Activate
    Dim sh As Shape
    Dim rangeToTest As Range
    Dim lRow As Long
    Dim c As Range
    lRow = ActiveSheet.Range("A" & ActiveSheet.Rows.Count).End(xlUp).Row
    Set rangeToTest = ActiveSheet.Range("A1:A" & lRow)
        For Each c In rangeToTest
            For Each sh In ActiveSheet.Shapes
                sh.Delete
            Next sh
        Next c
    ActiveSheet.Range("A1").EntireColumn.Hidden = True
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..
Does deleting shapes have something to do with comments?
 
     
     
     
     
     
    