Help with Macro

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
 
G

Guest

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

Guest

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

Dana DeLouis

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

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

Top