Help with Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following Macro is set up to hide 3 rows based on a cell reference. I now
need to change to hide 5 rows. Can anyone help me adjust it?

Sub HideStuff()
Dim rng As Range
For i = 7 To 130 Step 3
Set rng = Cells(i + 2, 3)
If rng.Value = "" Then
Cells(i, 1).Resize(3).EntireRow.Hidden = True
End If
Next
End Sub
 
As a guess

Sub HideStuff()
Dim rng As Range
For i = 7 To 130 Step 5
Set rng = Cells(i + 4, 3)
If rng.Value = "" Then
Cells(i, 1).Resize(5).EntireRow.Hidden = True
End If
Next
End Sub

Hard to tell without knowing your sheet...
 
Sorry I should have mentioned in my previous post that 130 is probably no
longer the correct number and needs to be changed. The code I posted will be
a problem as the number 130 will never actually be reached. It will be
something like 132 or 137 or something like that...
 
Would this work?

Sub HideStuff()
Dim R 'Row
Const k As Long = 5

For R = 7 To 130 Step k
Rows(R).Resize(k).Hidden = (Cells(R + k - 1, 3) = vbNullString)
Next
End Sub

HTH :>)
 
Back
Top