+ Reply to Thread
Results 1 to 7 of 7

Hide/Unhide Rows

  1. #1
    Registered User
    Join Date
    10-25-2012
    Location
    Ne/Ia
    MS-Off Ver
    office 2016
    Posts
    52

    Hide/Unhide Rows

    I found some Useful code, but i need it to do more.

    [code]
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Range("B4").Value = 0 Then
    Rows("14:16").EntireRow.Hidden = True
    Else
    Rows("14:16").EntireRow.Hidden = False
    End If
    End Sub
    [code]

    if i add rows above this code it adds the next row in the range to the hide list, but never unhides the additional row.

    Needed:

    I want to hide certain rows that do not need to be seen until a value is entered elsewhere.
    I want to apply this to several sets of rows, even if i need multiple macros.

    The rows that i want to hide will be located below the main body of the report, so row numbers will increase constantly however;
    No rows will be added to the hidden selection, only values will change.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Hide/Unhide Rows

    One way to do this is to create a named range in the row(s) you want to hide or unhide. Name a cell (Formulas/Define Name), e.g. "MyName1". The code for hiding the row of that cell is:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    511

    Re: Hide/Unhide Rows

    Hi this works for me

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-25-2012
    Location
    Ne/Ia
    MS-Off Ver
    office 2016
    Posts
    52

    Re: Hide/Unhide Rows

    RHCPgergo,

    I think the named range would work. i am new to code, how would a make that into a macro i could assign to a button?
    Last edited by Hooty; 02-15-2013 at 07:38 PM.

  5. #5
    Registered User
    Join Date
    10-25-2012
    Location
    Ne/Ia
    MS-Off Ver
    office 2016
    Posts
    52

    Re: Hide/Unhide Rows

    Toonies,
    I tried your code, but when i inserted rows above it the effected rows did not move lower in the order.

  6. #6
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Hide/Unhide Rows

    This is based on the OP, feel free to change it around.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-25-2012
    Location
    Ne/Ia
    MS-Off Ver
    office 2016
    Posts
    52

    Re: Hide/Unhide Rows

    RHCPgergo,

    Thank you! I used 2 named ranges instead of a cell value!

+ 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