PDA

View Full Version : Solved: check duplicate data in different worksheets



marreco
01-16-2013, 03:56 PM
Hi.
I found this routine done by, Patel45, and tried to adapt.

the problem is that it is taking too long to finish.

could someone help me?
Sub Teste_Patel45()
Dim cell As Range, cella As Range, rng As Range, srng As Range
Set rng = Sheets(2).UsedRange
Set srng = Sheets(1).UsedRange
Application.ScreenUpdating = False
For Each cell In rng
For Each cella In srng
If cella = cell Then
cella.Offset.Cells(1, 7).Value = "Sim"
End If
Next cella
Next cell
Application.ScreenUpdating = True
End Sub

I need to check duplicate data in different worksheets, and writing palavrea "yes" in column "G" Worksheet 1

thank you!!

mancubus
01-16-2013, 04:57 PM
hi.
try this:


Sub Teste_Patel45()
Application.ScreenUpdating = False
With Worksheets("Sheet1")
For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
If Application.CountIf(Worksheets("Sheet2").Range("A2:A" & Worksheets("Sheet2").Range("A" & .Rows.Count).End(xlUp).Row), .Cells(i, 1)) > 0 Then .Cells(i, 7) = "Sim"
Next i
End With
Application.ScreenUpdating = True
End Sub

marreco
01-16-2013, 05:05 PM
Hi.
it looks great!

thank you very much!!

mancubus
01-16-2013, 05:10 PM
you are most welcome. i am glad it helped.