+ Reply to Thread
Results 1 to 18 of 18

Move all highlighted duplicate names plus social security numbers to another sheet

  1. #1
    Registered User
    Join Date
    08-30-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    9

    Move all highlighted duplicate names plus social security numbers to another sheet

    Hello all
    This is my very first post to this forum and I must say I’m very happy to have found this site, I hope you guys can help me out.
    My problem is the following.
    I have an excel sheet with more than 57000 rows and 7 columns.
    Some of the rows are highlighted and some are not.
    First column contains first and last names and 2nd columns contain Social Security Numbers.
    I want to move all duplicate names plus social security numbers that are highlighted from the non-highlighted ones to another sheet.
    You can sort the data alphabetically.
    In other word, if I find a row that is highlighted and name and social security number in that row matches another non-highlighted row, move the highlighted row to another sheet.
    All the rows have names but some of them are missing social security numbers. If you find and empty social security numbers cell, jump over that row.
    I have been working on this one off and on all day today and I have a deadline at 2:00 pm tomorrow.
    So please if any of you gurus out there can help me out, I’ll be tank full for years to come :)
    I will include an example file.
    Thanks for your time and any help
    PS: a Macro would be the best way to go for me.
    Regards, Mel Shad
    Attached Files Attached Files
    Last edited by JBeaucaire; 08-30-2012 at 10:40 PM. Reason: Corrected thread title to topic only, as per forum rules, don't forget!

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    Try this,

    Please Login or Register  to view this content.
    Edit attached wrong code and book.
    Last edited by JapanDave; 08-30-2012 at 11:30 PM.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Registered User
    Join Date
    08-30-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    Dave thanks a lot for your help man. However, the code you send me generates an error.

    "Run-time error '9'
    Subscript out of range."

    And when I try to degug, it selects the code: cel = j(i, 1) & j(i, 2)

    I don't get it at all.
    thanks for your help and time

  4. #4
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    I realized that when I put the button on sheet2 after I posted and have reposted it ,but I was too late.

    Try this , this works.

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

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

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    Hi Mel and welcome to the forum,

    This looks like an Advanced Filter problem to me with the Unique box checked. It would help if you told us why some rows are highlighted. Is there a reason or formula for the hightlights?

    Read http://www.contextures.com/xladvfilter01.html or
    http://office.microsoft.com/en-us/ex...003073425.aspx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    How about this?
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-30-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    Thanks again for the fast reply man.
    It works but there are some problems.

    1. it looks as if it only finds the first set of duplicates and if i ad more duplicates in the rows it generates runtime error.

    2. the code should move the records to the 2nd sheet and not copy it.

    3. another error is when the names and last names are duplicates but not the Social Security Number. or when Social Security Number is duplicate and not the names.
    (i know that the Social Security Number can't be duplicates in reality but I'm just testing.)

    4. should i sort the rows alphabetically before running the macro or not?

    Once again, thanks a ton for all your help man, I really need to get this going....thanks

  8. #8
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    All this info would have been helpful before I wrote the code. Your sample workbook shows none of these anomalies.

    Why do you need the data moved and not copied? What the purpose of the highlighted cells? What are you trying to achieve?

    And please remember that you are working with a huge amount of data, so moving stuff around , although is not impossible will slow the code down a great deal.
    Last edited by Cutter; 09-02-2012 at 10:17 AM. Reason: Removed whole post quote

  9. #9
    Registered User
    Join Date
    08-30-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    hi there Jindon and thanks for your post.

    I can't see your code. its password protected. can you please provide me the password so i can see what its doing?

    I need to insert the code into my main sheet and I can't do it this way.

    thanks for your help man.

  10. #10
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    Quote Originally Posted by jindon View Post
    How about this?
    Jindon, what is the point of posting a workbook with a password on a help forum?

  11. #11
    Registered User
    Join Date
    08-30-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    the sheet is the result of merging 2 sheets.
    1 sheet had no highlights and the other one had lots of highlighted rows.

    we need to merge the 2 sheets and than do the following.

    1. comparing the highlighted with the non-highlighted ones.

    2. if we find a record that exist in highlighted and in non-highlighted and are exactly the same (same first name and Social Security Number) than move the highlighted record (row) into another sheet.

    3. if the names are the same but SSN is not the same, jump over that, (do nothing and go to next record).

    4. if the SSN is the same and name is not, again jump over that as well.

    5. if any row is missing name or SSN, again jump over that row and go to next row.

    this is what im trying to achieve and I hope you can help.

    Thanks a ton man, i really really appreciated what you doing.
    Regards, Mel Shad

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    Quote Originally Posted by Mel Shad View Post
    hi there Jindon and thanks for your post.

    I can't see your code. its password protected. can you please provide me the password so i can see what its doing?

    I need to insert the code into my main sheet and I can't do it this way.

    thanks for your help man.
    Seems working?

    Here's the code.
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    08-30-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    thanks for your help Jindon, but your code doesn't work.

    it looks like a tough problem to solve.

    this is what I'm trying to do:

    1. comparing the highlighted with the non-highlighted ones.

    2. if we find a record that exist in highlighted and in non-highlighted and are exactly the same (same first name and Social Security Number) than move the highlighted record (row) into another sheet.

    3. if the names are the same but SSN is not the same, jump over that, (do nothing and go to next record).

    4. if the SSN is the same and name is not, again jump over that as well.

    5. if any row is missing name or SSN, again jump over that row and go to next row.

    this is what im trying to achieve and I hope you can help.

    I will include a new file with more duplicates and missing data in it so you guys can work your magic easier.

    thanks again to all you guys out there who tried to help me out. thanks a ton
    Attached Files Attached Files

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    Working perfectly to me
    Attached Files Attached Files

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

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    Hi Mel,

    I guess my answer got lost in the approach above. Here is an example of what I wanted you to try. See if it works for you.

  16. #16
    Registered User
    Join Date
    08-30-2012
    Location
    Los Angeles
    MS-Off Ver
    Excel 2007
    Posts
    9

    Thumbs up Re: Move all highlighted duplicate names plus social security numbers to another sheet

    Hello all

    I must say you guys are all the best there is.
    All of you really did a great job and I have to thank each and every one of you guys that posted and helped a guy in need.

    Dave, Jindon and Marvin thank you. thanks for all the time and help you gave me.
    This morning I ran the code and it just worked like a dream. It took somewhere around 30 - 45 sec for it to find all the duplicates in 57291 and 7 columns and move them to another sheet. Is that a long time or not, I just have no idea. never done anything like this before. And don't get me wrong. I'm not complaining in any way, just wanted you guys to know how fast or slow your code was in the real world.

    Anyways, just wanted to thank you all one more time for all the help.
    Marvin, Ill test your way on my next sheet and will let you know the result. It will be some time in future.

    All the best
    Mel Shad.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    Mel

    Looping through the cells looking back ground color takes time.
    If you can mark the row that need to be removed in one column, it will be much much faster.

  18. #18
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Move all highlighted duplicate names plus social security numbers to another sheet

    @ Mel Shad

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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