Hi
I have this macro that was given to me and im trying to get it set up so that i can run it on one sheet only.
Can this be done?
Thanks
I have this macro that was given to me and im trying to get it set up so that i can run it on one sheet only.
Code:
Sub compare_data()
Dim sh1 As Worksheet, sh2 As Worksheet
Dim i As Long, j As Long, lr As Long
Set sh1 = ActiveWorkbook.Sheets("Sheet1")
Set sh2 = ActiveWorkbook.Sheets("Sheet2")
Application.ScreenUpdating = False
lr = sh1.Range("A" & sh1.Rows.Count).End(xlUp).Row
For i = 2 To lr
Application.StatusBar = "Checking row : " & i & " of : " & lr
j = Application.CountIfs(sh2.Columns("A"), sh1.Cells(i, "A").Value, sh2.Columns("B"), sh1.Cells(i, "B").Value, sh2.Columns("C"), sh1.Cells(i, "C").Value, _
sh2.Columns("D"), sh1.Cells(i, "D").Value)
Select Case j
Case 0
sh1.Cells(i, "E").Value = "MISSING"
Case 1
sh1.Cells(i, "E").Value = "OK"
Case Is > 1
sh1.Cells(i, "E").Value = "DUPLICATE"
End Select
Next
MsgBox "Done"
End Sub
Can this be done?
Thanks