looking for duplicates between two workbooks

user125

New Member
Joined
Feb 20, 2020
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to create a code that would potentially look for duplicates between two workbooks. What the code is doing right now is looking at cell "C2" ("Umbrella") and looking at the other workbook(i.e. Workbook2) for the value in column C until the last row. If the values match, the code looks at all cells in rng1 (i.e. "D26" until last used row) and looks for duplicates in column D until last row of Workbook2 . If both conditions are true, it changes the table value to "ti- duplicate found" and moves on to check the next row and so on...

Code:
Public Sub TiDuplicates(ws As Worksheet)
Dim lastrow As Long
Dim pathname As String
Dim foldername As String
Dim wb As Workbook
Dim i As Long
Dim cell1 As Range
Dim rng1 As Range

pathname = Mapping.Range("Task_Repository_Path")
foldername = Mapping.Range("Task_Repository_File_Name")
Workbooks.Open pathname & foldername
Set wb = Workbooks(foldername)
lastrow = wb.Worksheets("Sheet1").Cells(Rows.count, "C").End(xlUp).row
Set table = ws.Range("Meeting_Notes").Offset(0, 1)
Set rng1 = ws.Range("Task_Name:D" & Cells(Rows.count, "D").End(xlUp).row)
    
While table.row < ws.Range("Takeaways").row
If LCase(table(1, 1).value) = "ti" Then
For i = 5 To lastrow
       If ws.Range("Umbrella").Offset(0, 1) = wb.Worksheets("Sheet1").Cells(i, "C") Then
For Each cell1 In rng1
       If cell1.value = wb.Worksheets("Sheet1").Cells(i, "B") Then
table.value = "ti- duplicate found"
    
End If
Next cell1
End If
Next i
End If
Set table = table.Offset(1, 0)
Wend

What I need my code to do: need to change this part of the code "wb.Worksheets("Sheet1").Cells(i, "C")" so that it looks at all the used rows in Column C for duplicates and not just one row(i.e. i). Same goes for "wb.Worksheets("Sheet1").Cells(i, "B")".

I would be happy to answer any questions you have about the code or further explanation on what I am trying to create. Thank you! :)
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,215,059
Messages
6,122,913
Members
449,093
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top