Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
.....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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
....."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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Hide Column If Usedrange of Column ISBLANK Follow-up | Excel Discussion (Misc queries) | |||
Hide Column If Usedrange of Column ISBLANK | Excel Discussion (Misc queries) | |||
How to hide a column | Excel Discussion (Misc queries) | |||
Hide column or row based on a cell in the column or row? | Excel Discussion (Misc queries) | |||
How to hide a column when value=1 | Excel Programming |