+ Reply to Thread
Results 1 to 7 of 7

Deleting a row with empty cells

  1. #1
    Registered User
    Join Date
    07-28-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    7

    Deleting a row with empty cells

    Can anyone help me. I have a spreadsheet that is about 5000 rows long. I need a macro that will search the selection (A9:E5000) look for empty cells and delete the row.
    Not as it happens but after initiating the macro. Here is what i was using but it is not working.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 07-28-2011 at 08:38 PM. Reason: Added Code Tags

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Deleting a row with empty cells

    Hi Stevekag and welcome to the forum. Please take a moment to read the forum rules located in my signature and wrap code tags around your code as per Rule #3. Once you do that, someone will be able to help you.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Deleting a row with empty cells

    If you could also confirm - do you want to delete the row if any of the cells in a row are empty, say if B10 is empty but A10 and C10 are not you want Row 10 deleted, or do each of the cells have to be empty (i.e. A10, B10, C10, D10 and E10) for Row 10 to be deleted?
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Registered User
    Join Date
    07-28-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Deleting a row with empty cells

    Sorry Mordred here is the VBA code.

    Please Login or Register  to view this content.
    @Trevor76 - I am wanting to delete the entire row if anything in column D is empty. I did replace [selection] with [ ("D9:D5000") ] but i keep coming up with errors and i cannot seem to figure out what i have done.
    Last edited by Leith Ross; 07-28-2011 at 08:38 PM. Reason: Added Code Tags

  5. #5
    Registered User
    Join Date
    07-28-2011
    Location
    Buffalo, NY
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Deleting a row with empty cells

    Hey Stevekag hopefully my first post will be helpful:

    Please Login or Register  to view this content.

    Column F counts the cells in A through E that are not empty. If less than 5 cells are filled, it delete the entire row and moves onto the next row.

    Let me know if it works or you have any questions.

  6. #6
    Registered User
    Join Date
    07-28-2011
    Location
    Buffalo, NY
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Deleting a row with empty cells

    I posted my response before you clarified that you were looking empty rows in column D. The code posted will delete any rows in which any column is empty.

    Here is a simpler code that will delete rows that have an empty cell in column D:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-28-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Deleting a row with empty cells

    @kwg2200 thank you so much, i had been struggling with that forever. Much appreciated. :-)

+ 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