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