+ Reply to Thread
Results 1 to 6 of 6

Help with Macro

  1. #1
    Steve
    Guest

    Help with Macro

    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


  2. #2
    Jim Thomlinson
    Guest

    RE: Help with Macro

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

    --
    HTH...

    Jim Thomlinson


    "Steve" wrote:

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


  3. #3
    KR
    Guest

    Re: Help with Macro

    Replace "Step 3" with "Step 5"....

    "Steve" <sgauer@neo.rr.com.nospamallowed> wrote in message
    news:7526BBCD-0344-41C5-9878-4C6B72242CAA@microsoft.com...
    > 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
    >




  4. #4
    Steve
    Guest

    RE: Help with Macro

    Worked great. Thanks for the quick response.

    Steve

    "Jim Thomlinson" wrote:

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


  5. #5
    Jim Thomlinson
    Guest

    RE: Help with Macro

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

    Jim Thomlinson


    "Jim Thomlinson" wrote:

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


  6. #6
    Dana DeLouis
    Guest

    Re: Help with Macro

    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 :>)
    --
    Dana DeLouis
    Win XP & Office 2003


    "Steve" <sgauer@neo.rr.com.nospamallowed> wrote in message
    news:7526BBCD-0344-41C5-9878-4C6B72242CAA@microsoft.com...
    > 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
    >




+ 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