+ Reply to Thread
Results 1 to 6 of 6

Thread: Hide/Unhide a range of rows when cell is empty

  1. #1
    Registered User
    Join Date
    12-29-2011
    Location
    New Iberia, LA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Hide/Unhide a range of rows when cell is empty

    First thanks in advance, you guys are great and I appreciate the help.

    I have a sheet that I use to request pricing. I am a novice with VBA
    I can’t make the "Hide/Unhide Empty" button work.
    When cell G10 is blank I want row 10:14 to hide
    When cell G16 is empty I want row 16:20 to hide
    Also they the ranges need to unhide when a number is placed in either G10 or G16. Can anyone offer a VBA solution?

    ANY HELP WOULD BE APPRECIATED
    Last edited by chuck edwards; 01-05-2012 at 04:30 PM.

  2. #2
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brasil
    MS-Off Ver
    Excel 2007
    Posts
    497

    Re: Hide/Unhide a range of rows when cell is empty

    Try this..

    Sub Macro1()

    If Range("G10") = "" Then
    Rows("10:14").EntireRow.Hidden = True
    ElseIf Range("G16") = "" Then
    Rows("16:20").EntireRow.Hidden = True
    End If

    End Sub

  3. #3
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brasil
    MS-Off Ver
    Excel 2007
    Posts
    497

    Re: Hide/Unhide a range of rows when cell is empty

    sorry....
    ..
    If Range("G10") = "" And Range("G16") = "" Then

  4. #4
    Registered User
    Join Date
    12-29-2011
    Location
    New Iberia, LA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Hide/Unhide a range of rows when cell is empty

    I tried it and could not make it work I am sure it is my fault .

  5. #5
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brasil
    MS-Off Ver
    Excel 2007
    Posts
    497

    Re: Hide/Unhide a range of rows when cell is empty

    With the open Excel press Alt + F11.
    Then press Alt + I + M

    Copy and paste the code inside the module, after press F5 to run the macro.

  6. #6
    Registered User
    Join Date
    12-29-2011
    Location
    New Iberia, LA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Hide/Unhide a range of rows when cell is empty

    marreco thank you for your help I pasted this:

    Sub Macro1()

    If Range("G10") = "" And Range("G16") = "" Then
    Rows("10:14").EntireRow.Hidden = True
    ElseIf Range("G16") = "" Then
    Rows("16:20").EntireRow.Hidden = True
    End If

    End Sub

    and did as you instructed only nothing happens. The fist assembly has a number in cell G10 and G16 IS empty so I expected to see G16 and the assosiated rows collapse but nothing. Thank you for your help.

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