I try the nested for-loop at the past, but data checking is time consuming. So I decide to use vlookup to compare and get the data from another worksheet. I have searched many samples which is only for one workbook. In my code, the variable 'found' get error result, all values are display "NULL".
Please help to solve it...thank you!
Sub marco()
Dim rn As Integer
Dim x As Integer
Dim findmain As Variant
Dim found As Variant
Dim r As Range
Workbooks.Open ("c:\ABC.xls")
Workbooks("ABC.xls").Sheets(1).Range("a1:iv65536").Copy
ThisWorkbook.Sheets(1).Range("a1").PasteSpecial
Workbooks.Open ("c:\AA.xls")
Workbooks("AA.xls").Sheets(1).Range("a1:iv65536").Copy
ThisWorkbook.Sheets(2).Range("a1").PasteSpecial
rn = 3930
rn2 = 12613
x = 4
For i = x To rn
findmain = ThisWorkbook.Sheets(1).Cells(x, 3)
Set r = ThisWorkbook.Sheets(2).UsedRange
found = Application.VLookup(findmain, r, 11, 0)
If IsError(found) Then
ThisWorkbook.Sheets(1).Cells(x, 26) = "NULL"
Else: ThisWorkbook.Sheets(1).Cells(x, 26) = found
End If
x = x + 1
Next i
Bookmarks