Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy loop
I want to hide the entire row, if the value in column b is Yes.
So, I tried this: Private Sub CAT() For b = 1 To 25 If Cells(1, b) = "Yes" Then Selection.EntireRow.Hidden = True End If Next b End Sub If cell B1 is Yes, it hides that row, but not any other rows with Yes in column B. I don't know how to correct it. Thanks, -- Howard |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy loop
that is because you are looping over columns, not rows:
Private Sub CAT() For b = 1 To 25 If Cells( b,"B") = "Yes" Then Selection.EntireRow.Hidden = True End If Next b End Sub or Private Sub CAT() For b = 1 To 25 If Cells( b, 2) = "Yes" Then Selection.EntireRow.Hidden = True End If Next b End Sub -- Regards, Tom Ogilvy "Howard" wrote: I want to hide the entire row, if the value in column b is Yes. So, I tried this: Private Sub CAT() For b = 1 To 25 If Cells(1, b) = "Yes" Then Selection.EntireRow.Hidden = True End If Next b End Sub If cell B1 is Yes, it hides that row, but not any other rows with Yes in column B. I don't know how to correct it. Thanks, -- Howard |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Easy loop
Thank you very much!
-- Howard "Tom Ogilvy" wrote: that is because you are looping over columns, not rows: Private Sub CAT() For b = 1 To 25 If Cells( b,"B") = "Yes" Then Selection.EntireRow.Hidden = True End If Next b End Sub or Private Sub CAT() For b = 1 To 25 If Cells( b, 2) = "Yes" Then Selection.EntireRow.Hidden = True End If Next b End Sub -- Regards, Tom Ogilvy "Howard" wrote: I want to hide the entire row, if the value in column b is Yes. So, I tried this: Private Sub CAT() For b = 1 To 25 If Cells(1, b) = "Yes" Then Selection.EntireRow.Hidden = True End If Next b End Sub If cell B1 is Yes, it hides that row, but not any other rows with Yes in column B. I don't know how to correct it. Thanks, -- Howard |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Pretty easy If loop - help!! | Excel Worksheet Functions | |||
How easy is it to loop in VBA based on cell contents? | Excel Worksheet Functions | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
new user with easy question? not easy for me | New Users to Excel |