+ Reply to Thread
Results 1 to 4 of 4

Macro to Filter and delete Duplicate rows

  1. #1
    Registered User
    Join Date
    12-15-2010
    Location
    Oregon, USA
    MS-Off Ver
    Excel 2007
    Posts
    48

    Macro to Filter and delete Duplicate rows

    Hi guys,
    I have a worksheet with 10 columns of data in it. All columns have headers. I want to write a macro to filter data in Column A on criteria X first and then Column B for criteria Y and then go look for duplicates in column E and F and delete that entire row. I mean for example if E11 and F11 are same as E20 and F20, then delete Row20.

    Any help will be highly appreciated.

    Thank you.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Macro to Filter and delete Duplicate rows

    Hi Roop,

    Is the problem to get a better set of data or to learn to write macros?

    You can use Advanced Filter to get to one state and remove duplicates for the second.

    What did you really want?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    12-15-2010
    Location
    Oregon, USA
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Macro to Filter and delete Duplicate rows

    Hi marvin ,
    i am learning to write macros. The real problem i am having is to specify the first row and last row for my range becuase they change when i change my filter criteria. So, any help you can provide me for finding out the first row below header and last row of the visible data after applying filter will mcuh appreciated .

    Thank you.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Macro to Filter and delete Duplicate rows

    Hi Roop,
    Finding the last non-blank cell in a row is a standard for writing most VBA code.

    Look on the net for xlUp on the net. I've had to learn this myself and there are a few ways to get this number.

    For the last row I've standardized on the code:

    Dim LastRow as Double
    LastRow = Cells(Rows.count, "A").End(xlUp).Row

    There are many other ways to get this important number also.
    Read: http://www.tushar-mehta.com/excel/vb...and%20code.htm for many others.

+ 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