MrExcel Publishing
Your One Stop for Excel Tips & Solutions

I have a macro to hide rows depending on value but it won't loop through each row????


Posted by Angela on February 10, 2002 6:40 PM

Sub macro()
If[A1].Value=1 Then
Range("c4:g4").EntireRow.Hidden=True
End if
If[A1].Value=>1 Then
Range("c4:g4").EntireRow.Hidden=False
End if
End Sub

I can't get this macro to loop through rows. It seems it will only pick one row and hide that depending on value, it won't go onto another row. Any suggestions??? Or am I going about it wrong?? Any help would be appreciated!!! Thanks.


Posted by anno on February 10, 2002 7:54 PM

some tips on loops here - http://www.xl-logic.com/pages/vba.html, or here http://www.ozgrid.com/VBA/VBALoops.htm [nt]

Posted by Orsino on February 10, 2002 11:56 PM


Your code says :-
- if the value in A1 = 1, hide row 4
- if the value in A1 > 1, unhide row 4

What is it that you want to do ?