Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Column Width?

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
This works to test if a row is hidden...
Code:
Public Function IsHiddenRow(par1 As Range) As Boolean
    IsHiddenRow = False
    If par1.Cells(1, 1).Rows.Height = 0 Then IsHiddenRow = True
End Function

However this does not work for Columns...
Code:
Public Function IsHiddenRow(par1 As Range) As Boolean
    IsHiddenRow = False
    If par1.Cells(1, 1).Columns.Width = 0 Then IsHiddenRow = True
End Function

Any Ideas?
 


Hi,

RowHeight = 0 is not hidden.

BTW, your function does work. Why do you say it does not?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


I am mistaken. a ZERO row height or column width is symonimous with hidden. So, this code would work for either...
Code:
Public Function IsHidden(par1 As Range, Optional RC As String = "Row") As Boolean
    Select Case RC
        Case "Row": IsHidden = par1.EntireRow.Hidden
        Case "Column": IsHidden = par1.EntireColumn.Hidden
    End Select
    
End Function

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
The first piece of code above works for rows, however I changed Rows.Height to Columns.Width and the second one did not work.

I tried your code calling it from =IsHidden(B2) and hid both the row and the column... neither of which changed the value to True
 
It works, both on a sheet and called in VBA.

Where did you paste the function?

How are you calling the function

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I pasted the code in a module. I wasnt sure how to call it exactly so I used =IsHidden(B2) as I was able to use in the sample i provided.

How are you calling it... or a better question how are you using it on a sheet? I am not familiar how to use it on a sheet and not through the vb edit panes.
 
I use it on the sheet like any other spreadsheet function. Be sure Calculation is AUTOMATIC or hit F9.

Can be called in code...
Code:
sub test()
  msgbox ishidden([B2])
end sub
With Column B & Row 2 hidden...

if I enter this formula and copy down...
[tt]
=ishidden(B2)
=ishidden(B3)
[/tt]
I get

True
False

if I enter this formula and copy across...
[tt]
=ishidden(B2,"Column")
=ishidden(C2,"Column")
[/tt]
I get

True
False



Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top