#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default hide column

Try this:

Dim i As Integer, ws as worksheet
For Each ws in ActiveWorkbook.Worksheets
For i = 1 To 255
If ws.Cells(3, i).Value = 1 Then
ws.Columns(i).Hidden = True
End If
Next
Next


Steph wrote:

Hi. Is there a way to have vba scan every visible worksheet, and look in
row 3. If there is a 1 in a cell in row 3, hide that column? Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default hide column

.....and what about when we get spreadsheets with more columns?

On 14 Nov, 16:55, "Andrew Taylor" wrote:
Try this:

Dim i As Integer, ws as worksheet
For Each ws in ActiveWorkbook.Worksheets
For i = 1 To 255
If ws.Cells(3, i).Value = 1 Then
ws.Columns(i).Hidden = True
End If
Next
Next



Steph wrote:
Hi. Is there a way to have vba scan every visible worksheet, and look in
row 3. If there is a 1 in a cell in row 3, hide that column? Thanks!- Hide quoted text -- Show quoted text -


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 296
Default hide column

On 20 Nov 2006 05:17:50 -0800, "WhytheQ" wrote:

Just change the 255 to 17576

HTH


....and what about when we get spreadsheets with more columns?

On 14 Nov, 16:55, "Andrew Taylor" wrote:
Try this:

Dim i As Integer, ws as worksheet
For Each ws in ActiveWorkbook.Worksheets
For i = 1 To 255
If ws.Cells(3, i).Value = 1 Then
ws.Columns(i).Hidden = True
End If
Next
Next



Steph wrote:
Hi. Is there a way to have vba scan every visible worksheet, and look in
row 3. If there is a 1 in a cell in row 3, hide that column? Thanks!- Hide quoted text -- Show quoted text -


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default hide column

Hi Richard this doesn't really help if I've got 255 in 50 different
routines.
Encouraging generic code would be better approach.

Apologies for getting on my high horse.
J



On 20 Nov, 14:44, Richard Buttrey
wrote:
On 20 Nov 2006 05:17:50 -0800, "WhytheQ" wrote:

Just change the 255 to 17576

HTH





....and what about when we get spreadsheets with more columns?


On 14 Nov, 16:55, "Andrew Taylor" wrote:
Try this:


Dim i As Integer, ws as worksheet
For Each ws in ActiveWorkbook.Worksheets
For i = 1 To 255
If ws.Cells(3, i).Value = 1 Then
ws.Columns(i).Hidden = True
End If
Next
Next


Steph wrote:
Hi. Is there a way to have vba scan every visible worksheet, and look in
row 3. If there is a 1 in a cell in row 3, hide that column? Thanks!- Hide quoted text -- Show quoted text -__

Richard Buttrey
Grappenhall, Cheshire, UK
__________________________- Hide quoted text -- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default hide column

Agreed, my original posting went a bit too far in the "quick & dirty"
direction ;) Your "For Each cell in Rows(3)" construction is much
nicer.

Andrew




WhytheQ wrote:

Hi Richard this doesn't really help if I've got 255 in 50 different
routines.
Encouraging generic code would be better approach.

Apologies for getting on my high horse.
J



On 20 Nov, 14:44, Richard Buttrey
wrote:
On 20 Nov 2006 05:17:50 -0800, "WhytheQ" wrote:

Just change the 255 to 17576

HTH





....and what about when we get spreadsheets with more columns?


On 14 Nov, 16:55, "Andrew Taylor" wrote:
Try this:


Dim i As Integer, ws as worksheet
For Each ws in ActiveWorkbook.Worksheets
For i = 1 To 255
If ws.Cells(3, i).Value = 1 Then
ws.Columns(i).Hidden = True
End If
Next
Next


Steph wrote:
Hi. Is there a way to have vba scan every visible worksheet, and look in
row 3. If there is a 1 in a cell in row 3, hide that column? Thanks!- Hide quoted text -- Show quoted text -__

Richard Buttrey
Grappenhall, Cheshire, UK
__________________________- Hide quoted text -- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default hide column

....."quick and dirty": nice way to describe code!
If you fancy having a laugh, and looking at a really 'unusual' forum
poster, then try doing a search using "aaron.kempf@gmail" (make sure
you use Search Groups, rather than just This Group)
Mr Kempf certainly has a way with words and doesn't suffer fools
gladly!

Rgds
J


On Nov 27, 1:34 pm, "Andrew Taylor" wrote:
Agreed, my original posting went a bit too far in the "quick & dirty"
direction ;) Your "For Each cell in Rows(3)" construction is much
nicer.

Andrew



WhytheQwrote:
Hi Richard this doesn't really help if I've got 255 in 50 different
routines.
Encouraging generic code would be better approach.


Apologies for getting on my high horse.
J


On 20 Nov, 14:44, Richard Buttrey
wrote:
On 20 Nov 2006 05:17:50 -0800, "WhytheQ" wrote:


Just change the 255 to 17576


HTH


....and what about when we get spreadsheets with more columns?


On 14 Nov, 16:55, "Andrew Taylor" wrote:
Try this:


Dim i As Integer, ws as worksheet
For Each ws in ActiveWorkbook.Worksheets
For i = 1 To 255
If ws.Cells(3, i).Value = 1 Then
ws.Columns(i).Hidden = True
End If
Next
Next


Steph wrote:
Hi. Is there a way to have vba scan every visible worksheet, and look in
row 3. If there is a 1 in a cell in row 3, hide that column? Thanks!- Hide quoted text -- Show quoted text -__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -


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
Hide Column If Usedrange of Column ISBLANK Follow-up [email protected] Excel Discussion (Misc queries) 1 April 12th 09 10:00 PM
Hide Column If Usedrange of Column ISBLANK [email protected] Excel Discussion (Misc queries) 4 April 12th 09 09:47 PM
How to hide a column Pascale Excel Discussion (Misc queries) 4 February 27th 08 05:31 PM
Hide column or row based on a cell in the column or row? SacGuy Excel Discussion (Misc queries) 0 January 24th 06 06:51 PM
How to hide a column when value=1 angeloso Excel Programming 2 October 25th 05 12:08 PM


All times are GMT +1. The time now is 01:19 PM.

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

About Us

"It's about Microsoft Excel"