Repetition of Code

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

Guest

I need to repeat the following code for rows 1 to 135. If the value of the
cell in Column G is false, I need to hide the whole row. Rather than type in
masses of code, can anyone suggect some sort of loop to repeat 135 times.

If Worksheets("Quote").Range("G1") = False Then
Worksheets("Quote").Rows("1").Hidden = True
End If

Many thanks
 
Try something like this...

Sub HideRows()
Dim intCounter As Integer

With Sheets("Sheet2")
For intCounter = 1 To 135
If .Cells(intCounter, "G").Value = False Then _
.Rows(intCounter).Hidden = True
Next intCounter
End With
End Sub
 
That works great. Many thanks

Jim Thomlinson said:
Try something like this...

Sub HideRows()
Dim intCounter As Integer

With Sheets("Sheet2")
For intCounter = 1 To 135
If .Cells(intCounter, "G").Value = False Then _
.Rows(intCounter).Hidden = True
Next intCounter
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