ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Hiding rows based on a criteria thru and event proceedure (https://www.excelbanter.com/excel-worksheet-functions/157232-hiding-rows-based-criteria-thru-event-proceedure.html)

realmani

Hiding rows based on a criteria thru and event proceedure
 

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?


Zoltan

Hiding rows based on a criteria thru and event proceedure
 
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

"realmani" wrote:


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?



realmani

Hiding rows based on a criteria thru and event proceedure
 
On Sep 6, 2:42 pm, Zoltan wrote:
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

"realmani" wrote:

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?


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



All times are GMT +1. The time now is 03:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com