ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   writing macros to hide rows (https://www.excelbanter.com/excel-programming/307605-writing-macros-hide-rows.html)

steve

writing macros to hide rows
 
Hello,

I am trying to find a way to hide rows after running a
rule mechanism or macro.

For examplet there are 5 columns and a 1000 rows in which;

Specifically we would designate 2 out of the five rows in
which the other 3 rows would not be relevant.

For example cell A(1) and cell D(1) (in the same row) both
equal zero then hide that row.

We would want the search to run from the first to last row.

I am not sure if this is possible but your input would be
appreciated.

Regards

Ron de Bruin

writing macros to hide rows
 
Try this Steve for the usedrange

Sub Example1()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1
With ActiveSheet
.DisplayPageBreaks = False
For Lrow = Lastrow To Firstrow Step -1

If .Cells(Lrow, "A").Value = "0" And _
.Cells(Lrow, "D").Value = "0" Then .Rows(Lrow).Hidden = True

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


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


"Steve" wrote in message ...
Hello,

I am trying to find a way to hide rows after running a
rule mechanism or macro.

For examplet there are 5 columns and a 1000 rows in which;

Specifically we would designate 2 out of the five rows in
which the other 3 rows would not be relevant.

For example cell A(1) and cell D(1) (in the same row) both
equal zero then hide that row.

We would want the search to run from the first to last row.

I am not sure if this is possible but your input would be
appreciated.

Regards





All times are GMT +1. The time now is 03:21 AM.

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