ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hidind rows conditionally (https://www.excelbanter.com/excel-programming/312732-hidind-rows-conditionally.html)

henri

Hidind rows conditionally
 
I need to scan rows in a range and hide them according to
the value of one of their columns.

Basically:

For Cell= E1 to E650
if E(XX)=0 hide row where E(XX) is.
Next

Thanks in advance


Frank Kabel

Hidind rows conditionally
 
Hi
try:
Sub hide_rows()
Dim RowNdx As Long
Dim LastRow As Long
application.screenupdating=false
LastRow = ActiveSheet.Cells(Rows.Count, "E").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
if cells(RowNdx,"E").value=0 then
Rows(RowNdx).hidden = True
End If
Next RowNdx
application.screenupdating=true
End Sub


--
Regards
Frank Kabel
Frankfurt, Germany

"Henri" schrieb im Newsbeitrag
...
I need to scan rows in a range and hide them according to
the value of one of their columns.

Basically:

For Cell= E1 to E650
if E(XX)=0 hide row where E(XX) is.
Next

Thanks in advance



Ron de Bruin

Hidind rows conditionally
 
Try this Henri

Sub Example2()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 650
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "E").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "E").Value = "0" Then .Rows(Lrow).Hidden = True

End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


My new add-in have this option also
http://www.rondebruin.nl/easyfilter.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Henri" wrote in message ...
I need to scan rows in a range and hide them according to
the value of one of their columns.

Basically:

For Cell= E1 to E650
if E(XX)=0 hide row where E(XX) is.
Next

Thanks in advance




henri

Hidind rows conditionally
 
It looks like it's working.
Thanks to all of you !


-----Original Message-----
Hi
try:
Sub hide_rows()
Dim RowNdx As Long
Dim LastRow As Long
application.screenupdating=false
LastRow = ActiveSheet.Cells(Rows.Count, "E").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
if cells(RowNdx,"E").value=0 then
Rows(RowNdx).hidden = True
End If
Next RowNdx
application.screenupdating=true
End Sub


--
Regards
Frank Kabel
Frankfurt, Germany

"Henri" schrieb im

Newsbeitrag
...
I need to scan rows in a range and hide them according

to
the value of one of their columns.

Basically:

For Cell= E1 to E650
if E(XX)=0 hide row where E(XX) is.
Next

Thanks in advance


.



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

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