+ Reply to Thread
Results 1 to 8 of 8

Hide rows if all cells are blank

  1. #1
    Forum Contributor
    Join Date
    09-19-2003
    Posts
    226

    Hide rows if all cells are blank

    Hi

    I'm looking for a Macro that, if all cells in a row or rows are blank it will hide all those rows. I have rather a large worksheet with a few thousand rows.

    Many thanks

    Patish
    Patish

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Hide rows if all cells are blank

    Something like this ought to work:

    Please Login or Register  to view this content.
    This procedure figures out your bottom row by looking at the last row in Column A. If it should look in a different column, then change the "1" in - LastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row - to the number of the column that reaches down to the last row.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Hide rows if all cells are blank

    Hi cantosh,

    Did you know instead of using:

    LastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

    You can use the column letter, like:

    LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row

    I like to use the Column Letter instead of the number in my code.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Hide rows if all cells are blank

    Haha, yes I did. I habitually use the column number in my own code because it's a touch faster to type. Your comment, however, made me realize that having to type an explanation for the OP completely undid any efficiency I might've gained! I should probably start using the method that offers greater clarity when I'm posting for (potentially) newer users...

  5. #5
    Forum Contributor
    Join Date
    09-19-2003
    Posts
    226

    Re: Hide rows if all cells are blank

    Hi Guys

    I hope you don't mind if I attach a sample of the file. I don't want to waste your precious time.

    Let me summarise for you:

    - Columns A to E will never have blank cells.
    - If you go to column BC. The one highlighted in Yellow. It is the column that contains the total of the all the amounts in the rows between columns F to BB. If any cell in column BC is blank I want to hide the entire row.

    Does that sound better? I know, that's not really what I explained above. My apologies.

    Many thanks.
    Patish

  6. #6
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Hide rows if all cells are blank

    Patish.

    The code shared above should do as your asking. You just need to to adjust it to look at column BC like such

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Hide rows if all cells are blank

    Did you just want the blanks hidden?

    Please Login or Register  to view this content.
    If so this should work. However, some of your cells are showing a 0 value. This won't work for those.

  8. #8
    Forum Contributor
    Join Date
    09-19-2003
    Posts
    226

    Re: Hide rows if all cells are blank

    Thanks guys, for your quick replies.

    John, you asked if I want just the blanks hidden. The answer is no. If we take one row, for example. If there are no numbers in that row from columns F to BC (total will also be blank) I want that row to be hidden, including the contents of the cells from columns A to E. Bottom line I just want to see only the rows where there are numbers. The rest must be hidden.

    Now, here's the thing! The total may not always be in column BC. So, is there a way for me to be able to select the column that contains the total of the row and use that column to hide the blank rows?

    Thanks

    Patish

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Hide Rows for First Set of Consecutive Blank Cells in Column
    By pastuslm in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-22-2015, 03:22 PM
  2. [SOLVED] Hide rows when two cells are blank
    By Ravana in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-22-2015, 02:00 PM
  3. Hide Cells with zero values but blank rows should be ignored
    By ckozakos in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2011, 06:27 AM
  4. HIDE ZEROS IN CHART - Hide rows of cells that equals zero
    By sweedey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2011, 08:18 PM
  5. Hide all rows where a range of cells are blank
    By a45ward in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-02-2010, 06:29 AM
  6. Hide Blank rows
    By Charity in forum Excel General
    Replies: 15
    Last Post: 11-23-2006, 08:20 AM

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