ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   checking if a column is hidden (https://www.excelbanter.com/excel-programming/391130-checking-if-column-hidden.html)

John

checking if a column is hidden
 
How would i write this in VBA please. I would like to check if a selection
of columns is hidden, then take an action depending on the circumstance.

Thanks

John


Mike H

checking if a column is hidden
 
One way:-

Sub imhidden()
Columns("b:b").Select
If Selection.EntireColumn.Hidden = True Then
MsgBox ("Can't see me")
Else
MsgBox ("I'm visible")
End If
End Sub

Mike

"John" wrote:

How would i write this in VBA please. I would like to check if a selection
of columns is hidden, then take an action depending on the circumstance.

Thanks

John


Mike H

checking if a column is hidden
 
a bit neater

Sub imhidden()
If Columns("b:b").Hidden = True Then
MsgBox ("Can't see me")
Else
MsgBox ("I'm visible")
End If
End Sub

Mike

"John" wrote:

How would i write this in VBA please. I would like to check if a selection
of columns is hidden, then take an action depending on the circumstance.

Thanks

John


Bob Phillips

checking if a column is hidden
 
Public Sub Test()
Dim cHidden As Long
Dim col As Range

cHidden = 0
For Each col In Columns("E:H").Columns
If col.Hidden Then
cHidden = cHidden + 1
End If
Next col
MsgBox cHidden & " columns are hidden"
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"John" wrote in message
...
How would i write this in VBA please. I would like to check if a
selection
of columns is hidden, then take an action depending on the circumstance.

Thanks

John





All times are GMT +1. The time now is 09:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com