+ Reply to Thread
Results 1 to 10 of 10

Delete entire row if column a matches column d

  1. #1
    Forum Contributor
    Join Date
    09-29-2008
    Location
    usa
    MS-Off Ver
    EXCEL 2010
    Posts
    116

    Delete entire row if column a matches column d

    Does anyone have a macro that will delete entire row if column a matches column d
    Last edited by martinez_pedro; 08-19-2009 at 01:33 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Delete entire row if column a matches column d

    hi Martinez_Pedro,

    Do you mean something like this?
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    09-29-2008
    Location
    usa
    MS-Off Ver
    EXCEL 2010
    Posts
    116

    Re: Delete entire row if column a matches column d

    Hey Paul I get a run time error 424 with the code you posted
    But here is some sample data, on the real spreadsheet it can be up 26000 rows
    Attached Files Attached Files

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Delete entire row if column a matches column d

    Not sure why you get the error, but I see an issue with the code anyway (when deleting rows in VBA you should start at the bottom of the list so rows aren't skipped with the loop counter is incremented). Try this code instead:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    09-29-2008
    Location
    usa
    MS-Off Ver
    EXCEL 2010
    Posts
    116

    Re: Delete entire row if column a matches column d

    I try the second code and still saying
    Run Time Error 424 - Object Required
    Then I get the option debug or cancel if click debug it points at
    For i = UsedRange.Rows.Count To 1 Step -1
    do you thing its something worng with my excel(2007)?

  6. #6
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Delete entire row if column a matches column d

    I'm guessing you placed the code I gave you into a module rather than in the worksheet for which it applies. If you want to keep it in the module, you have to reference a sheet name or activesheet, e.g.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-29-2008
    Location
    usa
    MS-Off Ver
    EXCEL 2010
    Posts
    116

    Re: Delete entire row if column a matches column d

    I use the activesheet it work perfectly thank you very much

  8. #8
    Registered User
    Join Date
    05-18-2011
    Location
    internet
    MS-Off Ver
    Ontario
    Posts
    1

    Re: Delete entire row if column a matches column d

    worked like a charm for me thanks for the post

  9. #9
    Registered User
    Join Date
    01-16-2013
    Location
    illinois
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Delete entire row if column a matches column d

    What if the columns don't match up, but contain some of the numbers? For example, I'm scanning barcodes into an excel file, but would like a macro to take the numbers in a column from scanning, check a different column to see if those numbers match, and then delete the row that has a match. Column B is in order: 1,2,3,4,5,6, etc. Column C is not: 6,12,3,7,etc.

    Thanks!

  10. #10
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Delete entire row if column a matches column d

    MGalessi, per the Forum Rules (link in my signature below) please start your own thread for this question.

+ 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