+ Reply to Thread
Results 1 to 10 of 10

Very Difficult & Detailed Macro to find Duplicates

  1. #1
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299

    Very Difficult & Detailed Macro to find Duplicates

    I work with large spreadsheets. I was hoping that someone would know how to create a macro that will take selected cells in column C and search all of column C for exact duplicate entries. The macro envisioned would let you select cells to test. If a dulicate entry is found I would need the macro to test the cells in column E against one another. If both C & E match exact (if possible maybe display the findings in a pop up box) I would like the macro to ask me if I want to delete the duplicate entry, if yes, delete the entire row. If no, skip it and move to the next one. If C but not E match I would need the macro to ask me if I want to remove thetest cell. if yes, cut out the entire row of the TEST cell and paste it in a new sheet. If no skip it and move on.
    Am I just dreaming or can this be done. If it can be done, but more info is needed let me know.
    I thank you very much for your time and help and effort.

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    it can be done

    it would make it easier if you could paste an example of your workbook

  3. #3
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299
    In this example there are some duplicates for C only and some for both C&E. I would be without words if a macro could be built as described in my 1st post.

  4. #4
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299
    Sorry i dont't the file attached the 1st time, this should work.
    Also, remember, I need C to be an exact match. and if that is true then test E and so on.

    Thank you very much for your help.

    If you need another example or additional info let me know.
    Attached Files Attached Files
    Last edited by erock24; 02-23-2007 at 12:04 PM.

  5. #5
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299
    here is the same example, but more detailed to what I need.
    Also, in the example when I say delete I mean the whole row same goes for cut and paste.

    thank you
    Attached Files Attached Files
    Last edited by erock24; 02-23-2007 at 12:26 PM.

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Try this macro
    I beleive it does everyting you asked for

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299
    I am attempting to run your custom macro, but I am getting a run time error 448 "named argument not found" When I hit debug it highlights this part of your code.
    Set rFound = wS.Columns("c").Find(What:=Rng.Value, _
    After:=rFrom, LookIn:=xlFormulas, _
    LookAt:=xlWhole, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)

    I testing it on the sample sheet I gave you. I only selected one cell "C9". If I select a cell not in "C" and run macro. I get a message that says process finished.
    I have no doubt that this macro is going to be a life saver, once these tiny bugs are out. I thank you very much.
    Erock24.

  8. #8
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    When I test it on either of the 2 workbooks you posted it works ok.

    How are you running the macro. If it from a button on sheet you will need to change the TakeFocusOnClick property to False.

    The following code has a couple of minor fixes.
    Message will now only display if a cell in column 3 has been selected. - To remove message completed delete all code in Red.

    Test added to check selected cell in column 3 is not blank

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299
    At first I did try to run it from a button, but no matter how I try to run it I still get the same error and when I hit debug It highlights in yellow the following:

    Set rFound = wS.Columns("c").Find(What:=Rng.Value, _
    After:=rFrom, LookIn:=xlFormulas, _
    LookAt:=xlWhole, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)


    Is is something I'm doing wrong? I pasted the code by hit alt f11, insert module, and pasted it right in there. Then I close vb and select some cells in "c" to test, and run macro.

  10. #10
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    It could be because you are using an older version than. I have Excel 2003. If this is the case record a macro whilst you do a find in Excel. Post recorded macro & I will adapt my code.

    If you are using 2003 or later can you post a full copy of your workbook
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

+ 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