+ Reply to Thread
Results 1 to 12 of 12

Delete row if value exists in cell

  1. #1
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Delete row if value exists in cell

    I want, if D=0 or Blank, delete row. I can't even figure out how to do it with a single value.

    Nothing i find on google makes any sense to me


    *Edit

    If wasn't clear. If D3 was 0 or "" then D3 would delete. If D4 was 0 or "" then D4 would delete.
    Attached Files Attached Files
    Last edited by taylorsm; 12-20-2018 at 06:13 PM.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Delete row if value exists in cell

    What do you mean by
    then D4 would delete.
    Just clear contents ???

    Is it for column "D" or for any cell
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Delete row if value exists in cell

    Entire row.

    D4 = 0 or "" then EntireRow.Delete
    D5 = 0 or "" then EntireRow.Delete

    I have this, and it works almost. It is deleting a lot, but then just suddenly stops. It isn't getting all the blanks. If I rerun it, it will filter and show the blanks, but it will only delete the first instance. I

    With Sheets("Data").Range("E1", Range("E" & Rows.Count).End(xlUp))
    .AutoFilter Field:=1, Criteria1:=Array("="), Operator:=xlFilterValues
    .Offset(1).EntireRow.Delete
    .AutoFilter
    End With

  4. #4
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Delete row if value exists in cell

    Here is my exact code. If you run it you can see what I am talking about. It isn't deleting all the blanks.



    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Delete row if value exists in cell

    Hello Taylorsm,

    You need to clarify further. The sample in your post #1 has blanks or 0 in Columns D and E. Your sample in post #4 does not have any blanks or 0 in Columns D and E.

    Cheerio,
    vcoolio.

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Delete row if value exists in cell

    Here again the question about column reference: Is it column "D" to check or all columns ???

  7. #7
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,268

    Re: Delete row if value exists in cell

    try this code i am has test if lot data untll 200.000 row is more faster if using filter
    Please Login or Register  to view this content.
    "ThankyouFor Attention * And Your Help!!"

  8. #8
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Delete row if value exists in cell

    i'm sorry, i'm not sure where i'm losing everyone. The workbook and code should help. I am just deleting a row if the value in the "D#" cell is one of those options. Check value of D#, if value then delete THAT row. repeat through all

  9. #9
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Delete row if value exists in cell

    Quote Originally Posted by vcoolio View Post
    Hello Taylorsm,

    You need to clarify further. The sample in your post #1 has blanks or 0 in Columns D and E. Your sample in post #4 does not have any blanks or 0 in Columns D and E.

    Cheerio,
    vcoolio.
    If you run my code then it will. #4 is exactly what I start with, you run my code and it will delete select columns, THEN you end up with with the blanks/0 in the correct columns. Sorry my first post skipped a few steps, but I wanted to give the complete picture.



    OK so issue relates to that E not having a value and therefore xlendup is stopping to soon. I can redirect it to look at A and will likely have no issues, but how do I locate the last row of data, regardless of column
    Last edited by taylorsm; 12-21-2018 at 09:59 AM.

  10. #10
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Delete row if value exists in cell

    Please Login or Register  to view this content.
    see if that helps

  11. #11
    Forum Contributor
    Join Date
    01-09-2016
    Location
    USA,USA
    MS-Off Ver
    2016
    Posts
    1,192

    Re: Delete row if value exists in cell

    Type mismatch error

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Delete row if value exists in cell

    Works on your attachment in your first Post.
    Please Login or Register  to view this content.

+ 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 Subtotal if It Exists
    By skellz022782 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-11-2016, 08:27 AM
  2. [SOLVED] Delete sheet if it exists
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-15-2015, 03:08 PM
  3. Delete row if file exists
    By platesigns in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2014, 03:17 PM
  4. Delete rows where value exists
    By sreejaas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2012, 08:15 AM
  5. if a worksheet exists delete it
    By pavlos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2010, 03:15 AM
  6. Delete worksheet IF it exists
    By treva26 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-24-2007, 10:01 PM
  7. If worksheet exists delete
    By cereldine in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-13-2006, 12:30 PM

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