+ Reply to Thread
Results 1 to 6 of 6

Macro to Delete Row if Cell in Column D contains specific value

  1. #1
    Registered User
    Join Date
    06-11-2011
    Location
    Carrboro, NC
    MS-Off Ver
    Excel 2010
    Posts
    32

    Macro to Delete Row if Cell in Column D contains specific value

    I'm trying to come up with a macro that will delete an entire row if column D contains the value "0, 0" I had a macro that was working fine, but recently, it has started to delete the first row of data, even if that row does NOT include "0, 0" anywhere in it. So, I guess it would also be good if this macro starts looking at column D AFTER the first row. Any help would be greatly appreciated. Thanks!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to Delete Row if Cell in Column D contains specific value

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 03-14-2012 at 01:21 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    06-11-2011
    Location
    Carrboro, NC
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Macro to Delete Row if Cell in Column D contains specific value

    Thanks for the quick reply! Unfortunately, that code doesn't appear to work. It leaves all rows untouched. Does that code search for instances of "0, 0" in column D? It doesn't look like it...

    Perhaps more information would help. In my worksheet, column D includes concatenated addresses, in the form of City, STATE. In the event that a case has neither a city or state, the value in column D shows up as "0, 0"--with a "0" in the city field concatenated with a "0" in the state field (joined by a comma and space). Basically, I want to delete any row that has invalid city, state data--and thus a "0, 0" in column D. Does that help?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to Delete Row if Cell in Column D contains specific value

    My apologies, you should see the edit above now.

  5. #5
    Registered User
    Join Date
    06-11-2011
    Location
    Carrboro, NC
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Macro to Delete Row if Cell in Column D contains specific value

    I hate to be difficult, but I just tried the revised code and it didn't work either. Rows that clearly have "0, 0" in column D were not deleted. Any idea what might be going wrong? Thanks again.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to Delete Row if Cell in Column D contains specific value

    Do those cells have anything else in those same cells or is that the entire value? If there's more in that cell, then perhaps:

    Please Login or Register  to view this content.

    You can post a sheet and I can take a look...Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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