Hiding rows based on a criteria thru and event proceedure

  • Thread starter Thread starter realmani
  • Start date Start date
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?
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top