|
Sub AutoMatch()
Dim rng As Range, r1 As Integer, r2 As Integer, r3 As Integer
For r1 = 2 To Sheet1.[a65536].End(3).Row
Set rng = Sheet2.Range("b2:b65536").Find(Sheet1.Cells(r1, 1))
If rng Is Nothing Then
r2 = 32767
Else
r2 = Sheet2.Range("b2:b65536").Find(Sheet1.Cells(r1, 1)).Row
End If
Sheet1.Cells(r1, 2) = Sheet2.Cells(r2, 3)
Set rng = Sheet3.Range("b2:b65536").Find(Sheet1.Cells(r1, 1))
If rng Is Nothing Then
r3 = 32767
Else
r3 = Sheet3.Range("b2:b65536").Find(Sheet1.Cells(r1, 1)).Row
End If
Sheet1.Cells(r1, 3) = Sheet3.Cells(r3, 3)
Next r1
End Sub |
|