![]() |
Hide Columns
Hi,
I referred back to another entry about hiding columns and tried to use it. It didn't work. I created a drop down list in A5. Then all across from E1 to HE1, I used a simple if statement if the headers in row 6 equal to what the selected drop down is, then is give value of 1, else blank. Question is, why doesn't this work? Please help. Dim c As Range Dim varvalue As Variant For Each c In Application.Intersect(ActiveSheet.UsedRange, ActiveSheet.Range("E1:HI1")).Cells varvalue = c.Value If IsNumeric(varvalue) Then If varvalue < 1 Then c.EntireColumn.Hidden = True End If End If Next c |
Hide Columns
why not a simpler approach Sub hidecolsif() For Each c In Range("e1:hl1") If c = 1 Then Columns(c.Column).Hidden = True Next c End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "MrRJ" wrote in message ... Hi, I referred back to another entry about hiding columns and tried to use it. It didn't work. I created a drop down list in A5. Then all across from E1 to HE1, I used a simple if statement if the headers in row 6 equal to what the selected drop down is, then is give value of 1, else blank. Question is, why doesn't this work? Please help. Dim c As Range Dim varvalue As Variant For Each c In Application.Intersect(ActiveSheet.UsedRange, ActiveSheet.Range("E1:HI1")).Cells varvalue = c.Value If IsNumeric(varvalue) Then If varvalue < 1 Then c.EntireColumn.Hidden = True End If End If Next c |
Hide Columns
or columns("a:hb").hidden=false -- Don Guillett Microsoft MVP Excel SalesAid Software "MrRJ" wrote in message ... Hey Don, Boy, you are so smart! It is most definitely simpler. I added this line first, to unhide all the cells first prior to the "selection". Range("A:HB").EntireColumn.Hidden = False It works beautifully. Thanks a million. MrRJ "Don Guillett" wrote: why not a simpler approach Sub hidecolsif() For Each c In Range("e1:hl1") If c = 1 Then Columns(c.Column).Hidden = True Next c End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "MrRJ" wrote in message ... Hi, I referred back to another entry about hiding columns and tried to use it. It didn't work. I created a drop down list in A5. Then all across from E1 to HE1, I used a simple if statement if the headers in row 6 equal to what the selected drop down is, then is give value of 1, else blank. Question is, why doesn't this work? Please help. Dim c As Range Dim varvalue As Variant For Each c In Application.Intersect(ActiveSheet.UsedRange, ActiveSheet.Range("E1:HI1")).Cells varvalue = c.Value If IsNumeric(varvalue) Then If varvalue < 1 Then c.EntireColumn.Hidden = True End If End If Next c |
All times are GMT +1. The time now is 03:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com