Home » excel » excel – how to identify grouped column and hidden column separately?

excel – how to identify grouped column and hidden column separately?

Posted by: admin April 23, 2020 Leave a comment

Questions:

I have one excel containing few grouped columns. Inside that group few columns are HIDDEN.( right click hide). When the group is collapsed .Hidden property of all the columns returns true, which I don’t want. Is there is way to identify originally Hidden columns apart from other group columns in a collapsed group ?

How to&Answers:

don’t fully understand the question but in VBA I can test to see if a column is hidden like this:

Option Explicit

Sub TestFunction()

  'hide a few columns and then run me<<<<<<<<<<
  Dim mySearchColumn As Integer
  mySearchColumn = (CInt(Application.InputBox("input a column number")))

  MsgBox ("you wanted to know about column " & mySearchColumn & ". Is it hidden: " & IsColumnHidden(mySearchColumn))

End Sub

Function IsColumnHidden(targetColumn As Integer) As Boolean
    IsColumnHidden = False
    If Columns(targetColumn).EntireColumn.Hidden Then
        IsColumnHidden = True
    End If
End Function