writing macros to hide rows

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

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
 
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
 

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