ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   checking for hidden columns (https://www.excelbanter.com/excel-programming/348620-checking-hidden-columns.html)

stickandrock

checking for hidden columns
 
I want to create a macro that will validate whether a column is hidden or
not. I can make column hidden and/or unhide columns, but it is redudant if
they are already in the state that I need them.

Thank you for any and all input.

Charlie

checking for hidden columns
 
I don't think you need a macro to do that, just do:

If Not Columns(iCol).EntireRow.Hidden Then
Columns(iCol).EntireRow.Hidden = True
End If

But even that I quit doing long ago. Except in cases of heavy computation
where it's best to check first if something needs to be done, I've found it's
simpler just to do

Columns(iCol).EntireRow.Hidden = True

and not worry about if it is already hidden. The above statement uses so
little CPU time it's irrelevant whether or not it's already hidden.


"stickandrock" wrote:

I want to create a macro that will validate whether a column is hidden or
not. I can make column hidden and/or unhide columns, but it is redudant if
they are already in the state that I need them.

Thank you for any and all input.


chijanzen

checking for hidden columns
 
try,

Sub test()
'True=hide
MsgBox checkColumnshide(3)
End Sub

Function checkColumnshide(i As Integer) As Boolean
checkColumnshide = Columns(i).Hidden = True
End Function

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"stickandrock" wrote:

I want to create a macro that will validate whether a column is hidden or
not. I can make column hidden and/or unhide columns, but it is redudant if
they are already in the state that I need them.

Thank you for any and all input.


Charlie

checking for hidden columns
 
Sorry about the mix up between columns and rows. I cut, pasted, and modified
on the fly.

Columns(iCol).EntireColumn.Hidden


"Charlie" wrote:

I don't think you need a macro to do that, just do:

If Not Columns(iCol).EntireRow.Hidden Then
Columns(iCol).EntireRow.Hidden = True
End If

But even that I quit doing long ago. Except in cases of heavy computation
where it's best to check first if something needs to be done, I've found it's
simpler just to do

Columns(iCol).EntireRow.Hidden = True

and not worry about if it is already hidden. The above statement uses so
little CPU time it's irrelevant whether or not it's already hidden.


"stickandrock" wrote:

I want to create a macro that will validate whether a column is hidden or
not. I can make column hidden and/or unhide columns, but it is redudant if
they are already in the state that I need them.

Thank you for any and all input.


Mikerosoft

checking for hidden columns
 
What about if a column or row is grouped?


Charlie

checking for hidden columns
 
If you mean hiding/unhiding an individual row or column in a group, no
problem. You can do that. But if you mean hiding/unhiding all rows/columns
in a group at once, much like clicking the grouping buttons...good question!
I was unable to figure out how to do that. Anyone else have any ideas? (We
are using Excel 2002.)

"Mikerosoft" wrote:

What about if a column or row is grouped?




All times are GMT +1. The time now is 05:36 PM.

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