Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Mar 2004
    Location
    London, Gtr London, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to hide rows (WinXP Excel 2002)

    I would like a button on the toolbar which hides the current row ie the one containing the active cell. The button I can do, but dont know ho to write the macro behind it.
    Happy for anyone to help.

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Macro to hide rows (WinXP Excel 2002)

    <pre>activecell.EntireRow.Hidden = true
    activecell.offset(1,0).select</pre>

    should do what you want.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macro to hide rows (WinXP Excel 2002)

    <code>ActiveCell.EntireRow.Hidden=True</code>

    Should do what you want.

    StuartR

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Macro to hide rows (WinXP Excel 2002)

    I don't mind you responding before me, but where did you get the phrase "should do what you want." from?

    StuartR

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to hide rows (WinXP Excel 2002)

    Try this one:

    Sub HideRow()
    On Error Resume Next
    ActiveCell.EntireRow.Hidden = True
    End Sub

    The line "On Error Resume Next" avoids error messages if there is no open workbook, or if the active sheet is a chart sheet.

    If you want the macro to be available in all workbooks, store it in Personal.xls. See Legare Coleman's Personal.xls Tutorial (All) for details.

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Macro to hide rows (WinXP Excel 2002)

    Take your pick from:
    "Great minds think alike"
    and
    "Fools seldom differ" <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Macro to hide rows (WinXP Excel 2002)

    Consider yourself lucky that he hasn't trademarked it.
    -John ... I float in liquid gardens
    UTC -7ąDS

  8. #8
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to hide rows (WinXP Excel 2002)

    A more accurate statement would be "should do what you ASKED."
    Legare Coleman

Posting Permissions

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