![]() |
Loop learning
Hiding entire row, if value in cell in column B is Yes.
Private Sub CAT() Dim i As Long For i = 1 To 25 If Cells(i, 2).Value = "Yes" Then Rows(i).EntireRow.Hidden = True End If Next i End Sub Instead of using i = 1 to 25, can't I use the Count property? How would I do that? -- Howard |
Loop learning
Hi Howard
See the three delete macros on this page that use all a different loop http://www.rondebruin.nl/delete.htm The delete code start on the bottom and go up for hiding you can use both ways -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Howard" wrote in message ... Hiding entire row, if value in cell in column B is Yes. Private Sub CAT() Dim i As Long For i = 1 To 25 If Cells(i, 2).Value = "Yes" Then Rows(i).EntireRow.Hidden = True End If Next i End Sub Instead of using i = 1 to 25, can't I use the Count property? How would I do that? -- Howard |
Loop learning
Something like this:
Private Sub CAT() Dim i As Long For i = 1 To Activesheet.UsedRange.SpecialCells(xlCellTypeLastC ell).Row If Cells(i, 2).Value = "Yes" Then Rows(i).EntireRow.Hidden = True End If Next i End Sub "Howard" wrote: Hiding entire row, if value in cell in column B is Yes. Private Sub CAT() Dim i As Long For i = 1 To 25 If Cells(i, 2).Value = "Yes" Then Rows(i).EntireRow.Hidden = True End If Next i End Sub Instead of using i = 1 to 25, can't I use the Count property? How would I do that? -- Howard |
Loop learning
Thanks to both of you for advancing my limited knowledge!
-- Howard "Ron de Bruin" wrote: Hi Howard See the three delete macros on this page that use all a different loop http://www.rondebruin.nl/delete.htm The delete code start on the bottom and go up for hiding you can use both ways -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Howard" wrote in message ... Hiding entire row, if value in cell in column B is Yes. Private Sub CAT() Dim i As Long For i = 1 To 25 If Cells(i, 2).Value = "Yes" Then Rows(i).EntireRow.Hidden = True End If Next i End Sub Instead of using i = 1 to 25, can't I use the Count property? How would I do that? -- Howard |
All times are GMT +1. The time now is 04:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com