+ Reply to Thread
Results 1 to 3 of 3

Repetition of Code

  1. #1
    Steve
    Guest

    Repetition of Code

    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

  2. #2
    Jim Thomlinson
    Guest

    RE: Repetition of Code

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

    Jim Thomlinson


    "Steve" wrote:

    > 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


  3. #3
    Steve
    Guest

    RE: Repetition of Code

    That works great. Many thanks

    "Jim Thomlinson" wrote:

    > 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
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    >
    > "Steve" wrote:
    >
    > > 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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1