+ Reply to Thread
Results 1 to 14 of 14

Delete Entire Row if Blank is Found in Column

  1. #1
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Delete Entire Row if Blank is Found in Column

    Hello,

    I cannot find a solution online that works.

    If there are any blanks found in Column C, I want it to delete that entire row.

    However, these blank cells may not be adjacent to one another.

  2. #2
    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: Delete Entire Row if Blank is Found in Column

    Hi,

    The fastest way I know to do this is to use Autofilter for a blank on column C then select all he filtered rows and delete them.
    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.

  3. #3
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Delete Entire Row if Blank is Found in Column

    How do I select all filtered rows via VBA?

  4. #4
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Delete Entire Row if Blank is Found in Column

    I did exactly as you suggested via VBA, it is the actual deletion part I am stuck on.

  5. #5
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Delete Entire Row if Blank is Found in Column

    have you tried just running the single-line code?
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Delete Entire Row if Blank is Found in Column

    When I use the one-line I get Run-time error '1004': Delete method of Range class failed.

    I have non-adjacent rows.

  7. #7
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Delete Entire Row if Blank is Found in Column

    That 1004 error happens when there are no blank cells in the range of interest
    You can leave it as it is for an indicator that you don't have blank cells, but this is rarely done
    more usual is to include a line
    On Error Resume Next
    above the one line I gave
    or, if one wants to preserve the "one-liner" property then a conditional statement such as
    If Countblank(Range of interest) > 0 then ... (the one-line as posted above) can be used.

    If you've got lots of rows, say 100,000 or half a million or so and you want it done fast, then you can use a code like
    Please Login or Register  to view this content.
    this should be OK for smaller number of rows too
    Last edited by kalak; 09-16-2014 at 04:50 PM.

  8. #8
    Registered User
    Join Date
    05-14-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Delete Entire Row if Blank is Found in Column

    Hi There,

    I use this code for when i need to delete rows if empty or contains a set value.

    Please Login or Register  to view this content.
    Cheers

  9. #9
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Delete Entire Row if Blank is Found in Column

    Kalak,

    That code just deleted everything on my sheet...

  10. #10
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Delete Entire Row if Blank is Found in Column

    RandomPezzer -- your solution worked perfectly.

  11. #11
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Delete Entire Row if Blank is Found in Column

    Quote Originally Posted by EnigmaMatter View Post
    Kalak,

    That code just deleted everything on my sheet...
    Just to tidy up. Did you actually use the code that's now in Post#7?

    I'd modified an initial version shortly after posting. The initial version could have done as you say, which is why I changed it.
    It's very hard to see how the version now in Post#7 could have done this. It certainly didn't on any and all test data that I tried.

  12. #12
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Delete Entire Row if Blank is Found in Column

    I may have used the initial code.
    Thank You,

    EnigmaMatter

  13. #13
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Delete Entire Row if Blank is Found in Column

    Thanks for the feedback. That's always useful and encouraging to get.

    The RandomPezzer type of code is actually very widely used (and generally reliable) for this problem so I guess I was surprised you didn't find something like it online and were maybe looking for something different.

    The second last line is redundant, and if for any reason it's used instead of the earlier lr = ... then sometimes can get the wrong result.

  14. #14
    Forum Contributor
    Join Date
    02-04-2014
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    366

    Re: Delete Entire Row if Blank is Found in Column

    Well, I tend to find excellent VBA Subs and code on Google. I tend to find answers to many questions that way. However, this forum in particular tends to provide answers are better than what I find through search for.

+ 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. [SOLVED] Delete entire row if Column C is blank
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2014, 12:03 PM
  2. delete the entire row if duplicate found in column
    By gujugolf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-15-2013, 04:07 PM
  3. delete entire row if 'value' found anywhere in column - most efficient way?
    By intothewild in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-25-2012, 08:21 AM
  4. Replies: 6
    Last Post: 05-24-2012, 09:14 AM
  5. [SOLVED] To Delete the specific rows when blank is found on column A
    By ddiicc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-05-2005, 01:05 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