Đúng vậy, bạn có thể làm ơn thử lại giùm mình.
Dùng VLOOKUP được nhưng với dữ liệu nhiều, thì quá chậm.
Bạn Copy Code 1 sau vào Sheet Tim:
[GPECODE=vb]Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [C1]) Is Nothing Then
If WorksheetFunction.IsNumber([C1]) = True Then
Application.Run "Nhap_du_lieu.Nhapdulieu1"
End If
End If
End Sub[/GPECODE]
Sau đó bạn Copy Code 2 sau vào Module của File Up lên ở #1 => Bạn đổi tên Mudule đó thành tên là
Nhap_du_lieu:
[GPECODE=vb]Sub Nhapdulieu1()
Range([C8], [C65536].End(xlDown)).ClearContents
Sheets("DuLieu").Select
[G1].Select
[G1].AutoFilter Field:=7
Do While Not Range(ActiveCell, ActiveCell.End(xlDown)).Find("" & Sheets("Tim").[C1].Value & "", , , , , , False, False) Is Nothing
Range(ActiveCell, ActiveCell.End(xlDown)).Find("" & Sheets("Tim").[C1].Value & "", , , , , , False, False).Activate
If ActiveCell <> ActiveCell.Offset(-1, 0) And ActiveCell <> ActiveCell.Offset(1, 0) Then
Sheets("Tim").[C3] = ActiveCell.Offset(, -4)
Sheets("Tim").[C4] = ActiveCell.Offset(, -3)
Sheets("Tim").[C5] = ActiveCell.Offset(, -2)
Sheets("Tim").[C6] = ActiveCell.Offset(, -1)
Sheets("Tim").[C8] = ActiveCell.Offset(, 3)
ActiveCell.Offset(1, 0).Activate
Else
If ActiveCell <> ActiveCell.Offset(-1, 0) Then
Sheets("Tim").[C3] = ActiveCell.Offset(, -4)
Sheets("Tim").[C4] = ActiveCell.Offset(, -3)
Sheets("Tim").[C5] = ActiveCell.Offset(, -2)
Sheets("Tim").[C6] = ActiveCell.Offset(, -1)
Sheets("Tim").[C8] = ActiveCell.Offset(, 3)
Else
Sheets("Tim").[C7].End(xlDown).Offset(1, 0) = ActiveCell.Offset(, 3)
ActiveCell.Offset(1, 0).Activate
End If
End If
Loop
Sheets("Tim").Select
End Sub[/GPECODE]
* Ghi chú:
Nếu bạn không làm được các bước trên thì Download File đính kèm ở dưới để xài.
Cách dùng: Bạn gõ số 1 hoặc 2 hoặc 3 hoặc 4 vào ô C1 ở Sheet Tim => Sau đó Enter => Ra kết quả như bạn mong muốn.