+ Reply to Thread
Results 1 to 18 of 18

How to HIDE a row IF a certain cell is "" blank?

  1. #1
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    How to HIDE a row IF a certain cell is "" blank?

    Hello... How do I automatically HIDE/UNHIDE a row with code when one cell is blank ""? I know about the filtering, but it doesn't do HIDE/UNHIDE automatically, so that doesn't work.

    Thanks!

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: How to HIDE a row IF a certain cell is "" blank?

    Something like this...

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: How to HIDE a row IF a certain cell is "" blank?

    Okay, it doesn't work for me yet...

    This is what I did... I right-clicked on the Worksheet tab and selected "View Code" to open the VBA code for that worksheet. THen I pasted both code into it.

    Then when that didn't work, I tried editing the code and in every instance where you wrote "A", I edited to the range "A6:A200" which is the column in question. And that didn't work either...

    So the idea is, if anything in cells ("A6:A200") is "" blank, then automatically hide those rows. When those cells are filled again, then unhide.

    By the way, those cells have function code in them. But they're set to "" if the function results in a 0.

    Thanks again!

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to HIDE a row IF a certain cell is "" blank?

    Quote Originally Posted by nenadmail View Post
    Hello... How do I automatically HIDE/UNHIDE a row with code when one cell is blank ""? I know about the filtering, but it doesn't do HIDE/UNHIDE automatically, so that doesn't work.

    Thanks!
    Hi,

    It would if you created macro code to filter for non blanks.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: How to HIDE a row IF a certain cell is "" blank?

    I don't know how to code that... but I rather not use the "filter" because that filter icon that is created when using it is annoying, and in the way.

    By the way, the worksheet and workbook is protected, so keep that in mind for the codes.

  6. #6
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Add a reference for you

    PHP Code: 
    Option Explicit
    Sub HiddRowsForBlankCellInColumnA
    ()
     
    Dim hRng As Range
     
     Set hRng 
    Columns("A:A").SpecialCells(xlCellTypeBlanks)
     If 
    Not hRng Is Nothing Then
        hRng
    .EntireRow.Hidden True
        MsgBox 
    "Hidden " hRng.Count " rows"
     
    End If
    End Sub 

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: How to HIDE a row IF a certain cell is "" blank?

    Quote Originally Posted by nenadmail View Post
    By the way, the worksheet and workbook is protected, so keep that in mind for the codes.
    Quote Originally Posted by nenadmail View Post
    So the idea is, if anything in cells ("A6:A200") is "" blank, then automatically hide those rows. When those cells are filled again, then unhide.
    Some of these details are good up front.

    Call me crazy, but if the row is blank; therefore hidden, how do you enter something in it to unhide?

    Please share exactly what you desire...

  8. #8
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: How to HIDE a row IF a certain cell is "" blank?

    The worksheet is pure formula... and this row A6:A200 will change numbers data, or return "" if blank. Other worksheets that the user controls feed information here.
    Last edited by nenadmail; 05-23-2012 at 03:08 AM.

  9. #9
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: Add a reference for you

    I put the PHP code in the Sheet VBA... and it doesn't do anything. (By the way, there's no need for a Msg Box)...

    More info: This page is purely for "Printing"... and I don't want to print rows that return "" blank in A6:A200. It's an order form, and if there is "" blank amount of product to order, I don't want that to print that row. Again, it's a list that is feeding off of another even more detailed worksheet. So, A6:A200 cells are technically not empty, they have formula that is basically "paste link" data from the other worksheet. When no data, it returns "" blank.
    Last edited by nenadmail; 05-23-2012 at 03:08 AM.

  10. #10
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: How to HIDE a row IF a certain cell is "" blank?

    The "filter" feature almost worked. If there's code to make it constantly update and check for "" blank and constantly hide/unhide... that that will be fine.

  11. #11
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: How to HIDE a row IF a certain cell is "" blank?

    Okay I did some research, found the code below that works good. However, it only considers NUMBERS not text. So, if a cell contains TEXT and not a number, then it is hidden. Help me fix that please!

    Please Login or Register  to view this content.

    Also, it will not allow me to just select Col "A"... I have to have a range like A:B... I managed a way around that, but if the code can be fixed that would be better. What I did is add a new column that is always blank, and hid it....

    When I edit the code and just put:
    Please Login or Register  to view this content.
    Then errors come up.
    Last edited by nenadmail; 05-23-2012 at 06:25 AM.

  12. #12
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: How to HIDE a row IF a certain cell is "" blank?

    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  13. #13
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: How to HIDE a row IF a certain cell is "" blank?

    I tried it and this is the error I get:

    "Run-time error '91':
    Object variable or With block variable not set

    After I click on "Debug" it highlight in yellow the following:
    For Each rRow In rRowRange.Rows

  14. #14
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: How to HIDE a row IF a certain cell is "" blank?

    then you don't have anything in column A of that sheet.

  15. #15
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: How to HIDE a row IF a certain cell is "" blank?

    You're right... I had added a column for the previous code. BUT NOW IT WORKS PERFECTLY!!! THANK YOU SO MUCH!

  16. #16
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: How to HIDE a row IF a certain cell is "" blank?

    you're welcome. no need to holler though. :-P

  17. #17
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: How to HIDE a row IF a certain cell is "" blank?

    Oh, that wasn't hollering... I was just trying to make that text stand out more than the first part of the sentence, emphasizing for others that the thread is finally "solved."

  18. #18
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: How to HIDE a row IF a certain cell is "" blank?

    (I was joshing)
    ain't that what the mark solved thing is for? ;-)

+ 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