![]() |
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! |
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 - |
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 __________________________ |
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 - |
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 - |
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 - |
All times are GMT +1. The time now is 11:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com