+ Reply to Thread
Results 1 to 5 of 5

Hide rows with macro

  1. #1
    Registered User
    Join Date
    06-07-2006
    Posts
    3

    Hide rows with macro

    I have a question about hiding and unhiding rows with a Macro. I have searched trough the forum but I couldn't find the right solution for my specific problem.

    The situation is as follows:

    I have a sheet that I want to make a bit smaller, by hiding rows. The amount of visible rows can be entered in cell F7. The rows that should be hidden are rows 14 till 25.

    So if the number of visible rows entered in cell F7 is 1, row 14 unhides, if it's 2 row 14&15 unhide etc.

    Is there a way to do this in a Macro?

    Many thanks in advance for your help.

    ps. I'm sorry for any grammar or spelling mistakes, English is not my mother language

  2. #2
    Tom Ogilvy
    Guest

    RE: Hide rows with macro

    rows(14).Resize(Range("F7")).EntireRow.Hidden = False

    --
    Regards,
    Tom Ogilvy


    "Fugazy" wrote:

    >
    > I have a question about hiding and unhiding rows with a Macro. I have
    > searched trough the forum but I couldn't find the right solution for my
    > specific problem.
    >
    > The situation is as follows:
    >
    > I have a sheet that I want to make a bit smaller, by hiding rows. The
    > amount of visible rows can be entered in cell F7. The rows that should
    > be hidden are rows 14 till 25.
    >
    > So if the number of visible rows entered in cell F7 is 1, row 14
    > unhides, if it's 2 row 14&15 unhide etc.
    >
    > Is there a way to do this in a Macro?
    >
    > Many thanks in advance for your help.
    >
    > ps. I'm sorry for any grammar or spelling mistakes, English is not my
    > mother language
    >
    >
    > --
    > Fugazy
    > ------------------------------------------------------------------------
    > Fugazy's Profile: http://www.excelforum.com/member.php...o&userid=35179
    > View this thread: http://www.excelforum.com/showthread...hreadid=549471
    >
    >


  3. #3
    Ardus Petus
    Guest

    Re: Hide rows with macro

    Paste the following code in your Worksheet's code
    (right-click tab, select View code)

    HTH
    --
    AP

    '----------------------------------------------------------
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rNbRow As Range
    Dim lrow As Long

    Set rNbRow = Range("F7")
    If Intersect(Target, rNbRow) Is Nothing Then Exit Sub
    For lrow = 14 To 25
    Rows(lrow).Hidden = lrow >= rNbRow.Value + 14
    Next lrow

    End Sub
    '------------------------------------------------------------
    "Fugazy" <[email protected]> a écrit dans
    le message de news: [email protected]...
    >
    > I have a question about hiding and unhiding rows with a Macro. I have
    > searched trough the forum but I couldn't find the right solution for my
    > specific problem.
    >
    > The situation is as follows:
    >
    > I have a sheet that I want to make a bit smaller, by hiding rows. The
    > amount of visible rows can be entered in cell F7. The rows that should
    > be hidden are rows 14 till 25.
    >
    > So if the number of visible rows entered in cell F7 is 1, row 14
    > unhides, if it's 2 row 14&15 unhide etc.
    >
    > Is there a way to do this in a Macro?
    >
    > Many thanks in advance for your help.
    >
    > ps. I'm sorry for any grammar or spelling mistakes, English is not my
    > mother language
    >
    >
    > --
    > Fugazy
    > ------------------------------------------------------------------------
    > Fugazy's Profile:
    > http://www.excelforum.com/member.php...o&userid=35179
    > View this thread: http://www.excelforum.com/showthread...hreadid=549471
    >




  4. #4
    Ardus Petus
    Guest

    Re: Hide rows with macro

    Pffffffff
    I'm baffled!

    --
    AP

    "Tom Ogilvy" <[email protected]> a écrit dans le message
    de news: [email protected]...
    > rows(14).Resize(Range("F7")).EntireRow.Hidden = False
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Fugazy" wrote:
    >
    >>
    >> I have a question about hiding and unhiding rows with a Macro. I have
    >> searched trough the forum but I couldn't find the right solution for my
    >> specific problem.
    >>
    >> The situation is as follows:
    >>
    >> I have a sheet that I want to make a bit smaller, by hiding rows. The
    >> amount of visible rows can be entered in cell F7. The rows that should
    >> be hidden are rows 14 till 25.
    >>
    >> So if the number of visible rows entered in cell F7 is 1, row 14
    >> unhides, if it's 2 row 14&15 unhide etc.
    >>
    >> Is there a way to do this in a Macro?
    >>
    >> Many thanks in advance for your help.
    >>
    >> ps. I'm sorry for any grammar or spelling mistakes, English is not my
    >> mother language
    >>
    >>
    >> --
    >> Fugazy
    >> ------------------------------------------------------------------------
    >> Fugazy's Profile:
    >> http://www.excelforum.com/member.php...o&userid=35179
    >> View this thread:
    >> http://www.excelforum.com/showthread...hreadid=549471
    >>
    >>




  5. #5
    Registered User
    Join Date
    06-07-2006
    Posts
    3
    Wow, thanks for the swift and good replies!

    It worked

+ 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