+ Reply to Thread
Results 1 to 43 of 43

Using macros to find duplicates in two spreadsheets

  1. #1
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Using macros to find duplicates in two spreadsheets

    Hi all,

    I am a new poster on this forum. I tried getting help from another forum but no one there has offered any help for days now. My problem is this: I run an online baseball league, and the game I use to simulate our games has issued a new version which has updated ratings for all the baseball players. I have exported rosters from the new game and rosters from my online league to .csv files and what I want to do is find which players are duplicates in both files and line them so that I can scroll both files simultaneously and update my online league file easily. I also want the non-duplicate players to be sorted below the duplicates so I can deal with them later. Someone on the other forum posted some dynamic named range code and two macros and gave me some vague instructions on how to use the codes. I have posted the codes below with their instructions:

    In both:

    a) There're defined 2 dynamic named ranges:


    "DataTable" as: =DESREF(INDIRECTO(DIRECCION(COINCIDIR("//Player ID";updated_rosters!$A:$A;0)+2;1;1;1;"ml_rosters"));;;CONTARA(updated_rosters!$A:$A)-CONTAR.SI(updated_rosters!$A:$A;">=//");CONTARA(INDIRECTO("updated_rosters!$"&COINCIDIR("//Player ID";updated_rosters!$A:$A;0)&":$"&COINCIDIR("//Player ID";updated_rosters!$A:$A;0)))) -----> in english: =OFFSET(INDIRECT(ADDRESS(MATCH("//Player ID",updated_rosters!$A:$A,0)+2,1,1,1,"updated_rosters")),,,COUNTA(ml_rosters!$A:$A)-COUNTIF(updated_rosters!$A:$A,">=//"),COUNTA(INDIRECT("updated_rosters!$"&MATCH("//Player ID",updated_rosters!$A:$A,0)&":$"&MATCH("//Player ID",updated_rosters!$A:$A,0))))


    "DataUpdateTable" as: =DESREF(DataTable;0;25;56) -----> in english: =OFFSEF(DataTable,0,25,,56)


    The changes in the now weird range definitions are due to the first and last lines like "//..." that altered the normal and usual worksheet like database structures.


    b) In worksheet Sheet1 there's a procedure SortLinked in the VBA section:

    -----

    Please Login or Register  to view this content.
    -----


    c) There are 5 new columns ER:EV & ES:

    ER1: title

    ER2: Z (greater than below values for sorting descending because of damned row 2)

    ER3 & down: =SI(ES3=0;"N";"Y") -----> in english: =IF(ES3=0,"N","Y")

    ES1: title

    ES3 & down: =SI.ERROR(COINCIDIR(A3;'[XXX.xlsm]Sheet1'!$A:$A;0);0) -----> in english: =IFERROR(MATCH(A3,'[XXX.xlsm]Sheet1'!$A:$A,0),0) (where XXX is the name of the other file)

    ET1: title

    ET3 & down: =E3&"_"&F3&"_"&K3&"_"&J3&"_"&I3&"_"&L3&"_"&N3

    EU1: title

    EU2: 0 (lesser than 1, for sorting ascending)

    EU3 & down: =MIN(CONTAR.SI(ET$1:ET3;ET3);2) -----> in english: =MIN(COUNTIF(ET$1:ET3,ET3),2)

    EV1: title

    EV3 & down: "Y" if update, "" if not

    In OBSL file (target) there's a module with a procedure UpdateLinked in the VBA section:

    ----- />
    Please Login or Register  to view this content.
    -----


    Only once steps:

    1) update your workbooks as described in a), b) & c)

    2) define the named ranges in them as specified


    Each time steps:

    1) in both files run the procedure SortLinked

    2) in target (OBSL) file run the procedure UpdateLinked


    Just advise if any issue.


    Regards!


    PS: Remember that these files have crossed links, so if renaming happens you'd have to edit data links too.


    PS2: I'm gonna take vacations of baseball (specially ML & OBSL) for a few, long, days. Good luck!

    Here are my files if someone will please take a look at them and instruct me on how to use these codes. I have downloaded Spreadsheet Compare and KU Tools to try and figure this out but to no avail.

    New rosters: https://www.dropbox.com/s/xdpk0bndan...ed_rosters.csv

    Online league rosters: https://www.dropbox.com/s/8arhr605w4...sl_rosters.csv

    Thanks,

    Stacy
    Last edited by sborah99; 04-19-2014 at 07:37 PM. Reason: corrected CODE tags, not PRE tags.

  2. #2
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Hi Stacy,

    Firstly, welcome to the forum

    I dunno if I am speaking for others on the forum, but I took one look at your **lengthy** question, attempted to read through it and was left completely baffled. I think this is why you are getting such minimal response on your post....... It's way, way to complex! and BTW: that opening and utterly complex formula does not help to ignite any willingness, just a mild case of fear!!! LOL

    Anyways, back to the point. I think you'd get much more help if you did not present your ENTIRE project to the forum, but rather break it up into smaller pieces and let us help you with one challenge at a time. We do not know much about your needs and the comparison/analysis template you seem to want to design, so giving us the entire process just muddles with our minds -- and makes it appear as too much work. Many of us here are offering our time and effort freely and the forum is not intended as a platform for large project design.

    I think you'll find it much more beneficial to present us with a single scenario and get some solution on that. Then you can integrate it into your file and if needed, ask a second question, get help and integrate that; until you have a working model that suits you.
    Regards,
    Rudi

  3. #3
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Thanks for the reply, Rudi. The first piece of business with the new rosters and the online league rosters would be to compare them to each other and find out which players in the new rosters have duplicates in the online league rosters. Then, those duplicates would need to be sorted so that the same players line up between the new rosters and the online league rosters. Then, the last piece of business would be for the non-duplicate players in both rosters would be sorted below the duplicates in both rosters. I thought it would be a pretty simple matter to do all this. I would think there would be a wizard of some sort in Excel that would help me do this? If not, how would I go about doing this? I was able to do this last year with two other files, but for some reason, the macros aren't working with these files. Thanks again.

  4. #4
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    I guess the best way to put this would be, is there a way to compare two spreadsheets for duplicates and then align the duplicates in one spreadsheet to the duplicates in the other spreadsheet while at the same time sorting the non-duplicates at the bottoms of the two spreadsheets? Can it be done with any method other than macros? Thanks.

  5. #5
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Hi Stacy,

    The Pivot Table feature in Excel is a powerful tool that can take raw data and summarize, organize and compare info.
    In the sample file attached you will see a mock-up (with tiny amount of dummy data) in illustration of what I can suggest to compare players and find duplicates between the Original data and the Updated data. Using Pivots will certainly be the easiest and most flexible way to find duplicates and determine if they are withing the same .csv or duplicated between the two .csv files without the need for macros, formulas or any manual process.

    I'm not sure what ultimately needs to be done with these comparisons, but if it is simply to collect statistics, or find inconsistencies, then this is the way to go.

    In the mock-up the first sheet is the original data
    In the second sheet is based on the original with new updated names as well as deleted names from the originals
    The third sheet is a combination of both into one sheet
    The fourth sheet is the summary pivot table showing comparisons and identifying duplicates

    I'm hoping this will provide an idea of how you can compare these two lists with the least amount of effort on your part.
    Let me know what you think and if this is a viable option.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    My goal is not simply to find inconsistencies and collect the data. I need a way to align the duplicates in both files so that I can easily transfer the data from the updated_rosters file to the obsl_rosters file without putting data on the wrong lines. If you look at both files, you'll notice the first 65 lines show the same names and birthdays in both files. That is what I need to do with the entire files: have all the duplicate names line up so that I can take the data that starts in column Z through column EQ in the updated_rosters file and copy/paste it to the same columns in the obsl_rosters file. Then I need all the non-duplicate names sorted separately from the duplicates. Thanks.

  7. #7
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Understood.

    Instead of you doing this manually...(sorting, copying/pasting), we can script a macro to do this automatically.
    In stead of fussing with sort orders and syncorized scrolling, we can have the macro locate the player using some unique code between the files and then update the stats based on a find. The only important condition is that we need to determine a way to locate the player uniquely in the obsl_roster based on parameters in the updated_roster. Is there a way to do this? If we combine PlayerID and Name and Birthdate (for example), will it create an absolute unique code that can be located in the obsl_roster? If it can, then the macro can take the stats in Z - EQ and replace it with the updated stats.

    Is this a viable solution? If so...what fields will uniquely identify a player between the two files?
    TX

  8. #8
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Yes that is a very viable solution, Rudi. The best way to match them would be to compare their names and then their birthdates. If the names are similar and the birthdates are the same, then they are the same player. There will be some players with similar names and matching birthdates who may not match up (i.e., Luis Acosta on line 13 in updated_rosters and Luis Enrique Acosta on line 13 in obsl_rosters, both with birthdates of 28/11/1994 -- same player, just different method of naming him). In which case, it is best to just match up the last names with the birthdates. Thanks.

  9. #9
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Great. I'll start setting up a macro to deal with this.
    BTW: I'll include NationalityID too...just in case you get a same name and birthday. Better safe than sorry

  10. #10
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Good idea, thanks!

  11. #11
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Hi Stacy,

    Here is a template containing the macro.
    When you click the button it will do the following:

    1. It will prompt you for the two csv files. I assume that they are called opsl_rosters and updated_rosters. This is important as the code will be referring to these names.
    2. The code will start to run and process the opsl_rosters records, updating the stats with those from the updated_rosters. I have locked the screens so you will not see any movement. I did add a counter on Excel's status bar (bottom left) so you can see progress. The code will probably run for a few minutes due to the >10,000 records.
    3. Once the code is run, you will see that most codes in the Code column on the opsl_rosters sheet are blue. These are the records that were updated. The ones that are still balck text was not updated due to no matches in the updated_rosters sheet.

    Please run the code and see if you require any changes/modifications...
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    When I run the macro, it tells me that the macro cannot be run because the macro may not be available in this book or all macros have been disabled. I know the macros haven't been disabled. But could the problem be that you used "opsl_rosters" when it should be "obsl_rosters"? Or am I not running this correctly? I have both files I need to compare open but the template you made isn't asking me for them. Thanks.

  13. #13
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Never mind. I downloaded your template a second time and it's running fine now.

  14. #14
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Everything looks good, for the most part. I like that it updated the ratings of all the duplicate players automatically. Thank you for that! In the updated _rosters, is there a way to color the non-duplicate players red? I still need to add those players to the obsl_rosters but I will have to do those manually as there is a special procedure I have to follow that Excel can't do. Thanks.

  15. #15
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Hi,

    The records from updated which have no matches with those in obsl are now highlighted in RED.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Actually, I was wanting the non-duplicate players in the updated_rosters file colored red. Thanks.

  17. #17
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    OK...here it is...
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Perfect, Rudi! Exactly what I wanted to do! This template you made will work with other files as long as I change the file names and ranges, correct?

  19. #19
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Excellent...glad its working

    As long as the structure of the two cvs's are similar it will function fine. The amount of records in either does not matter...there is no need to change ranges. The macro calculates the height (or amount of rows) automatically and compensates for different amounts of rows.

    The file names (and sheet names) MUST be the same as what we have currently used. I have not written in any generalization for these (although it is possible to generalize them).

  20. #20
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Excellent! Thank you for your help! If I had money, you'd have a fistful coming your way!

  21. #21
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    TX, but unfortunately we don't use dollars here, so it won't help! LOL....

  22. #22
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Sorry to hear that!

    I need another small favor: In those same files I posted (updated_rosters and obsl_rosters), is there a way to compare the E and F columns in both files and, when there is a match, take the A column data from the updated_rosters and paste it into the obsl_rosters with the same blue color? Thanks.

  23. #23
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    I'll have a look...
    To confirm;
    1. If the combined data of E and F columns is the same in both sheets?
    2. Take ONLY the A column data of updated or take the entire column?
    3. Must it be added to the bottom (appended to) the obsl sheet (in blue colour)?

  24. #24
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Another thing (I have just opened those files again)...
    If the combined columns of E and F is to create a unique value to compare... I'd recommend to add one or two other fields to ensure uniqueness. In your volume of data, just Team Name and Last Name might have several duplicates....???

  25. #25
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Quote Originally Posted by RudiS View Post
    I'll have a look...
    To confirm;
    1. If the combined data of E and F columns is the same in both sheets?
    2. Take ONLY the A column data of updated or take the entire column?
    3. Must it be added to the bottom (appended to) the obsl sheet (in blue colour)?
    1. Correct
    2. ONLY the A column of data in the updated _rosters file
    3. No, overwrite column A data in the obsl_rosters file if the E and F columns are matches

    Thanks.

  26. #26
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Quote Originally Posted by RudiS View Post
    Another thing (I have just opened those files again)...
    If the combined columns of E and F is to create a unique value to compare... I'd recommend to add one or two other fields to ensure uniqueness. In your volume of data, just Team Name and Last Name might have several duplicates....???
    This time, it doesn't matter if several duplicates get the same data overwritten.

  27. #27
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    OK... I'll send the macro soon....

  28. #28
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Hi,

    See if this code provides the expected results...

    Please Login or Register  to view this content.

  29. #29
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    I got the Runtime error 9: Subscript out of range. And it highlighted the command "Set obsl = Worksheets ("obsl_rosters"). Which seems weird because I'm using the same files.

  30. #30
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Just check if there is no leading or trailing spaces in the sheet name.

  31. #31
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Nope, no leading or trailing spaces.

  32. #32
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    I tried putting .csv at the end of both files and I still get the same error.
    Last edited by sborah99; 04-25-2014 at 07:03 PM.

  33. #33
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Hi Stacy,

    That error is informing that the macro does not find a sheet called "obsl_rosters" in the current workbook in which you are running the code. Either the sheet is not existing or there is a spelling error in the name. I have run is successfully on my side each time. Maybe what you can do is first run the code that compares the two sheets and marks the records in blue and red. Once that code has run and the two sheets have been imported and processed, then run the macro in question. Actually the two can really be merged as this macro giving you the error simply is a continuation of the previous one.

    Let me know what happens if you run them one after the other: First the macro called: Update_obsl and then the one called: GetTeamPlayerMatches

  34. #34
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    That worked great! Thanks again, Rudi!

  35. #35
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Good to know

  36. #36
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Well, I'm back. I tried using the macro in Stacy.xlsm in post #17 on the same files and I get this error:

    Run-time Error '13': Type Mismatch

    And when I click Debug, this is the line that it says has a fault in it:

    upd.Range(upd.Cells(rC.Value, "Z"), upd.Cells(rC.Value, "EQ")).Copy rC.Offset(0, 26)

    Any idea what the problem is? I haven't messed with this at all. Here are links to the same files:

    https://www.dropbox.com/s/4ocl4ac9ni...sl_rosters.csv

    https://www.dropbox.com/s/7v3y05iuuk...ed_rosters.csv

    Thanks.
    Last edited by sborah99; 05-19-2014 at 11:24 AM.

  37. #37
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    Hi,

    The structure of your obsl_roster has changed.

    The macro does not take compensate for structural changes in the file. You will see that in the current obsl_roster there is a list of items above the actual player stats list. This is causing the error. See image 1: 1.jpg

    Either you must delete this data (and the row just below the column headings) or move this this data to the bottom of the file like it was in the original csv's that you posted. See image 2 which illustrated the data cleanup: 2.jpg

    Unfortunately the macro does not take this structural change into account. It might be best to check the file structures before you run the macro, and "clean" the lists if needed. Basically the macro expects the list to start in cell A1 and that the list does not have any blank rows. Also, I might mention that the names of the csv's must remain the same as they too are hard-coded into the macro. If you clean up the obsl_roster, the macro will run fine again.

  38. #38
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Of course! Thanks for answering my question! I feel dumb for not noticing that!

  39. #39
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Using macros to find duplicates in two spreadsheets

    No probs... Glad I could assist again.

  40. #40
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Hi all,

    You helped me greatly last year with this macro, and I have another question. I want to exclude a range of cells in my target file - specifically CO to DI - so that they are not updated. What would I change in the macro to achieve this? The macro is pasted below:

    Option Explicit

    Sub Update_obsl()
    Dim vFile As Variant
    Dim i As Integer
    vFile = Application.GetOpenFilename _
    (FileFilter:="Comma Separated Files, *.csv", MultiSelect:=True)
    If Not IsArray(vFile) Then
    MsgBox "No file was selected.", vbExclamation
    Exit Sub
    End If
    Application.ScreenUpdating = False
    For i = LBound(vFile) To UBound(vFile)
    Workbooks.Open Filename:=vFile(i)
    ActiveSheet.Move after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
    Range("A1").Value = "PlayerID"
    Range(Range("A:A").Find("//"), Cells(Rows.Count, 1)).EntireRow.Delete
    Columns("A").Insert
    Range("A1").CurrentRegion.Columns(1).Formula = "=SUBSTITUTE(RC[5]&RC[9]&RC[10]&RC[11]&RC[12],"" "","""")"
    Range("A1").CurrentRegion.Columns(1).Cells(1).Value = "Code"
    Next i

    Dim obsl As Worksheet, upd As Worksheet
    Dim rC As Range
    Dim lCnt As Long
    Dim rF As Range
    Set obsl = Worksheets("obsl_rosters")
    Set upd = Worksheets("updated_rosters")
    lCnt = obsl.Cells(Rows.Count, 1).End(xlUp).Row
    obsl.Activate
    With obsl
    .Columns("A").Insert
    .Range("A1").CurrentRegion.Columns(1).Formula = "=MATCH(RC[1],updated_rosters!C,0)"
    .Range("A1").CurrentRegion.Columns(1).Cells(1).Value = "Match"
    End With
    For Each rC In obsl.Range(Cells(2, 1), Cells(lCnt, 1)).Cells
    If rC.Row Mod 100 = 0 Then Application.StatusBar = "Progress: Row " & rC.Row & " of " & lCnt
    If Not IsError(rC.Value) Then
    upd.Range(upd.Cells(rC.Value, "Z"), upd.Cells(rC.Value, "EQ")).Copy rC.Offset(0, 26)
    rC.Offset(0, 1).Font.Color = vbBlue
    End If
    Next rC
    obsl.Columns(1).Delete
    upd.Activate
    With upd
    .Columns("A").Insert
    .Range("A1").CurrentRegion.Columns(1).Formula = "=MATCH(RC[1],obsl_rosters!C,0)"
    .Range("A1").CurrentRegion.Columns(1).Cells(1).Value = "Match"
    .Range("A1").AutoFilter Field:=1, Criteria1:="#N/A"
    .Range("A1").CurrentRegion.Offset(1, 0).Columns(2).Font.Color = vbRed
    .Columns("A").Delete
    .AutoFilterMode = False
    End With
    Worksheets(1).Activate
    Application.StatusBar = False
    Application.ScreenUpdating = True
    End Sub

    Thanks.

    Stacy

  41. #41
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Just in case they're needed, here are the files I am working with.

    The updated file:
    https://www.dropbox.com/s/9l05yjp723...sters.csv?dl=0

    The target file:
    https://www.dropbox.com/s/m450t0wld6...sters.csv?dl=0

    Thanks again.

  42. #42
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Using macros to find duplicates in two spreadsheets

    sborah, I need to poing out 3 things to you...

    1. for each new question, start a new thread
    2. use code tags when posting code
    3. upload workbooks to the forum, not all members are able - or willing - to use file-hostong sites.

    Thanks
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  43. #43
    Registered User
    Join Date
    04-19-2014
    Location
    Boaz, Alabama
    MS-Off Ver
    Excel 365
    Posts
    30

    Re: Using macros to find duplicates in two spreadsheets

    Quote Originally Posted by FDibbins View Post
    sborah, I need to poing out 3 things to you...

    1. for each new question, start a new thread
    2. use code tags when posting code
    3. upload workbooks to the forum, not all members are able - or willing - to use file-hostong sites.

    Thanks
    Will do. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to find duplicates, concatenate cells, then delete old duplicates
    By givemepuppies in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 03-04-2016, 02:43 AM
  2. [SOLVED] Macro to find duplicates, concatenate Unique Values, then delete old duplicates
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-17-2013, 04:32 PM
  3. Need Macros to find and list duplicates in a column
    By Karthik Sen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-13-2012, 03:41 PM
  4. Replies: 3
    Last Post: 02-28-2012, 06:42 AM
  5. Find Duplicates Between 2 Spreadsheets???
    By Seagood3 in forum Excel General
    Replies: 3
    Last Post: 04-12-2010, 01:37 PM

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