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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA/Excel: how do I test if columns.hidden = true?

Status
Not open for further replies.

larissalle

Technical User
Aug 28, 2001
10
0
0
US
I know how to test if activesheet.autofiltermode = true. Can I do something similar to test if there are any hidden columns in a worksheet? If true, I want to unhide them. If false, do nothing.

The following didn't work:
first select worksheet, then

If Selection.EntireColumn.Hidden = True then
Cells.Select
Selection.EntireColumn.Hidden = False
End If

 
Here's a simple routine that should accomplish what you're asking.

Sub CheckCols()
For Each col In ActiveSheet.Columns
If col.Hidden = True Then col.Hidden = False
Next
End Sub
 
Hi
Rather than test each column, if you want to make sure all columns are visible this line will do the trick

ActiveSheet.Columns.Hidden = False

This wil be slightly quicker but you probably won't notice the difference!

Hapy Friday
;-)

If a man says something and there are no women there to hear him, is he still wrong?
 
Thanks for the tips. I tried both and both worked. I ended up using the second one, columns.hidden = false, after I saw that it took no longer to just unhide all rather than first test if there were any hidden before unhiding.
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top