Hiding rows based on a criteria thru and event proceedure

R

realmani

I have data range L5:L100 which contains numbers. I want an event
proceedure which hide the rows if cell value is equal to zero.

Further i want this event proceedure assign to a button. Clicking on
it will perform the above task

Could anyone help?
 
Z

Zoltan

Hello,

try this:

Private Sub CommandButton1_Click()

Dim mycell As Range
Dim rng As Range

Set rng = Range("L5:L100")
For Each mycell In rng
If mycell.Value = 0 Then
Rows(mycell.Row).Hidden = True
End If
Next


End Sub

It goes thru the range and check each cell. If cell value is 0, then it
hides that specific row.
I hope I understood well your question.

Regards,
Zoltan
 
R

realmani

Hello,

try this:

Private Sub CommandButton1_Click()

Dim mycell As Range
Dim rng As Range

Set rng = Range("L5:L100")
For Each mycell In rng
If mycell.Value = 0 Then
Rows(mycell.Row).Hidden = True
End If
Next

End Sub

It goes thru the range and check each cell. If cell value is 0, then it
hides that specific row.
I hope I understood well your question.

Regards,
Zoltan

Thank you very much Zoltan!!!! that works perfectly
 
Top