+ Reply to Thread
Results 1 to 11 of 11

Delete Rows if a Cell is Blank?

  1. #1
    Registered User
    Join Date
    08-25-2008
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    80

    Delete Rows if a Cell is Blank?

    I have about 10 files that are each nearly 5,000 rows. I need to delete each row that totals to 0. Instead of going through each file and delete the rows as I scroll down, I am hoping there's another way to do it.

    I've attached a file. The last row (row D) has quite a few cells that are blank. I need to delete all of the rows that have blank cells in row D, but leave the ones that have values in row D, such as D94. Is there any way to do this withough deleting them as I go?

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Delete Rows if a Cell is Blank?

    What about rows that have "-" in them?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    08-25-2008
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    80

    Re: Delete Rows if a Cell is Blank?

    Sorry, yes, I would like to delete those too.

    Thanks

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Delete Rows if a Cell is Blank?

    You said you have 10 files which require this macro. Would you want this macro to open the file for you and then delete the rows? This way, you do not have to copy the same code to all the files but can use 1 macro for all files. However, you need to ensure that the sheet names are the same for the macro to work. Or you could even ask the macro for the sheetname.

  5. #5
    Registered User
    Join Date
    08-25-2008
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    80

    Re: Delete Rows if a Cell is Blank?

    Wow. Actually, the sheet names are the same for each file, so that may work quite well.

  6. #6
    Registered User
    Join Date
    08-25-2008
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    80

    Re: Delete Rows if a Cell is Blank?

    One thing I failed to mention, is that, if possible, I would like it to only check certain cells (which should be the same on each file). Looking at the attached file, it would be D9:D3435 and D3439:4875.

    Thanks!

  7. #7
    Registered User
    Join Date
    08-25-2008
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    80

    Re: Delete Rows if a Cell is Blank?

    Any possibility of this being solved? I really appreciate your effort!

  8. #8
    Valued Forum Contributor
    Join Date
    12-05-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010 & 2013
    Posts
    308

    Re: Delete Rows if a Cell is Blank?

    Hi there

    I'm most of the way there with this, but I have run out of time. Some points:
    1) SUMPRODUCT should be used, not SUM. Using SUM, you are forced to then add subtotals together. When subtotals are 0, and so deleted, the cell referencing it will return #REF. Subtotal avoids this error. I have substituted SUM with SUBTOTAL in the attached.
    2) I haven't managed to get the totals at the bottom to work. The issue is similar to that above.

    I hope this helps.
    US1000 RS.xlsm
    Cheers, Rob.

  9. #9
    Registered User
    Join Date
    08-25-2008
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    80

    Re: Delete Rows if a Cell is Blank?

    Thank you rscsmith. I appreciate your trouble and can see what you are saying. That definitely seems to be the first step in solving this problem.

    I was out of town last week, but am back now, so I'm still hoping the experts on here can help me with this problem.

    Thanks again!

  10. #10
    Registered User
    Join Date
    08-25-2008
    Location
    Texas
    MS-Off Ver
    2010
    Posts
    80

    Re: Delete Rows if a Cell is Blank?

    Any chance this is still possible?

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Delete Rows if a Cell is Blank?

    I tried this code on your file
    Please Login or Register  to view this content.
    But i found that its also causing #REF errors. How do you want to handle that? Do you want to delete rows that are blank but do not have formulae?

+ 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