Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Detect Hidden Columns

How can I detect if any columns have been hidden on a worksheet in vba?

I would like to use this to prevent a modal form (called from wsheet1)
initialising and also in a Workbook_BeforeClose event which contains 4
wsheets.

Geoff
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Detect Hidden Columns

Sub geoff()
For i = 1 To 256
If Columns(i).EntireColumn.Hidden = True Then
MsgBox ("column " & i & " is hidden")
End If
Next
End Sub
--
Gary''s Student
gsnu200711

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Detect Hidden Columns

Thank you, I can adapt from that.

Geoff

"Gary''s Student" wrote:

Sub geoff()
For i = 1 To 256
If Columns(i).EntireColumn.Hidden = True Then
MsgBox ("column " & i & " is hidden")
End If
Next
End Sub
--
Gary''s Student
gsnu200711

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Detect Hidden Columns

Given that people are using v2007 now, it would be better not to hard code
the row count:

Private Sub CommandButton1_Click()
Dim i As Long

With ActiveSheet.Columns
For i = 1 To .Count
If .Item(i).EntireColumn.Hidden = True Then
MsgBox "column " & i & " is hidden"
End If
Next
End With

End Sub

NickHK

"Gary''s Student" wrote in message
...
Sub geoff()
For i = 1 To 256
If Columns(i).EntireColumn.Hidden = True Then
MsgBox ("column " & i & " is hidden")
End If
Next
End Sub
--
Gary''s Student
gsnu200711



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Detect Hidden Columns

good point.


b.t.w - what's an item ?
--
Gary''s Student
gsnu200711



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Detect Hidden Columns

Collections have a member of .Item.

..Columns(i) is equivalent to .Columns.Item(i)

Only so I could include both in the With block.

NickHK

"Gary''s Student" wrote in message
...
good point.


b.t.w - what's an item ?
--
Gary''s Student
gsnu200711



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Detect Hidden Columns

thanks
--
Gary''s Student

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detect Hidden Columns by Formula David Godinger Excel Programming 5 January 9th 07 03:09 AM
Detect Hidden Rows by Formula David Godinger Excel Programming 7 January 6th 07 08:00 AM
How do I detect hidden worksheets or hidden data on a worksheet? Alice Excel Discussion (Misc queries) 4 August 24th 06 03:38 AM
How to detect if a workbook is hidden through VBA Aaron[_16_] Excel Programming 2 October 13th 05 07:10 PM
How to detect if sheet is hidden? hstijnen Excel Worksheet Functions 1 March 24th 05 02:40 PM


All times are GMT +1. The time now is 06:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"