+ Reply to Thread
Results 1 to 6 of 6

VBA code to hide empty rows

  1. #1
    Registered User
    Join Date
    03-19-2013
    Location
    Mpls, MN
    MS-Off Ver
    Excel 2010
    Posts
    3

    VBA code to hide empty rows

    Fairly new to VBA code, I am looking for a macro that will hide empty rows with in a sheet. My data starts in B8 and continues across to M8. Data could be populated in anyone of the columns, so I need it to look across all of the columns and hide the rows with out data in them. Currently, the sheet has 250+ rows but would like to have the option to add rows if needed and have them included in the macro.

    I currently have code that will look from B8 to M500 and it takes a while to run through. If it could look in only the cells that have formating (line borders) in them and hide only those rows, that would be helpful.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA code to hide empty rows

    Are all cells in a row blank? In other words if B10 is blank but C10 is not do you still want to hide the row? If not, then you can't "hide" individual cells. You can change the format to ";;;" which is kind of sudo hidden.

    Try:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-19-2013
    Location
    Mpls, MN
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA code to hide empty rows

    That code worked well, how can I include columns B through M. Right now it only looks in the B column?

    If there is data in one cell of the row from column B over to column M starting at Row 8. I do not want to hide it. If all cells in the row through all of the columns are empty, than those rows should be hidden.

    Thank you for your response!

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA code to hide empty rows

    Oh i see. This is very specific to the ranges you provided in your workbook. Try:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-19-2013
    Location
    Mpls, MN
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA code to hide empty rows

    Thank you for the quick response! I copy and pasted this code into the VBA ediitor and ran it but it does not hide anything data or no data.
    I don't think I did anything wrong.
    Any suggestions?

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA code to hide empty rows

    Works just fine for me. This seems to be an all too common response of mine. See attached test workbook.

    Testworkbook.xlsm

  7. #7
    Registered User
    Join Date
    10-15-2012
    Location
    Houston, TX, USA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Red face Re: VBA code to hide empty rows

    Wow...worked for me...just had to name th sheet by the true sheet name, not the tab name I was using (3 places to do this) and as I changed the columns I wanted, I see B-M=12 but I needed C-BE=55. ie, columns to be included.

    Sorry, I'm just a one off user and I was able to get it to work for me.

    Thank you so much!

+ 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