Nhờ GPE giúp đoạn code sau sai chỗ nào , mà khi khớp dữ liệu phần lớn kết quả đúng, nhưng một số chõ vẫn sai ( file ví dụ đính kèm)
Xin cám ơn
Sub KhopPhach()
With Application
.ScreenUpdating = False: .Calculation = xlCalculationManual
End With
Dim endR&, i&, j&
Dim sPhach$, sTmp$
Dim Arr(), ArrPh()
With Sheets("THop")
endR = .Cells(65000, 10).End(xlUp).Row
ArrPh = .Range("j7:l" & endR).Value
End With
With Sheets("In_ketqua")
endR = .Cells(65000, 10).End(xlUp).Row
Arr = .Range("j7:l" & endR).Value
End With
For i = 1 To UBound(Arr)
sPhach = CStr(Arr(i, 9) & Arr(i, 10))
For j = 1 To UBound(ArrPh)
sTmp = CStr(ArrPh(j, 1) & ArrPh(j, 2))
If Len(sTmp) > 0 Then
If sPhach = sTmp Then
Arr(i, 11) = ArrPh(j, 3)
GoTo Exit_For
End If
End If
Next j
Exit_For:
Next i
With Sheets("In_ketqua")
.[B7].Resize(UBound(Arr), 11) = Arr
End With
Erase Arr(), ArrPh()
With Application
.ScreenUpdating = True: .Calculation = xlCalculationAutomatic
End With
End Sub
Xin cám ơn
Sub KhopPhach()
With Application
.ScreenUpdating = False: .Calculation = xlCalculationManual
End With
Dim endR&, i&, j&
Dim sPhach$, sTmp$
Dim Arr(), ArrPh()
With Sheets("THop")
endR = .Cells(65000, 10).End(xlUp).Row
ArrPh = .Range("j7:l" & endR).Value
End With
With Sheets("In_ketqua")
endR = .Cells(65000, 10).End(xlUp).Row
Arr = .Range("j7:l" & endR).Value
End With
For i = 1 To UBound(Arr)
sPhach = CStr(Arr(i, 9) & Arr(i, 10))
For j = 1 To UBound(ArrPh)
sTmp = CStr(ArrPh(j, 1) & ArrPh(j, 2))
If Len(sTmp) > 0 Then
If sPhach = sTmp Then
Arr(i, 11) = ArrPh(j, 3)
GoTo Exit_For
End If
End If
Next j
Exit_For:
Next i
With Sheets("In_ketqua")
.[B7].Resize(UBound(Arr), 11) = Arr
End With
Erase Arr(), ArrPh()
With Application
.ScreenUpdating = True: .Calculation = xlCalculationAutomatic
End With
End Sub