Bạn dùng thử code này nhé:Nhờ các Anh Chị viết cotde giùm tôi về load dữ liệu (load cước vận chuyển hàng hóa) có vd đính kèm
Private Sub Worksheet_Change(ByVal Target As Range)
Dim h As Integer, i As Byte, Cll As Range
If Target.Column <> 10 Then Exit Sub
If Target.Value = "" Then Application.Union(Target.Offset(, 2), Target.Offset(, 4), Target.Offset(, 6), Target.Offset(, 8)).ClearContents
On Error GoTo Thoat
h = WorksheetFunction.Match(Target, Sheet2.[A:A], 1)
Set Cll = Sheet2.Cells(h, 1)
For i = 1 To 4
Target.Offset(, 2 * i).Value = Cll.Offset(, i)
Next i
Thoat:
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i, j, k
On Error Resume Next
i = Target.Row: k = 2
If i > 6 And InStr(1, "1;3;5;7", Target.Column - 10)>0 Then
For j = 1 To 7 Step 2
Cells(i, 11 + j) = WorksheetFunction.VLookup( _
Cells(i, 10 + j), Sheet2.Range("cuoc"), k)
k = k + 1
Next
Cells(i, 10) = Cells(i, 11) + Cells(i, 13) + Cells(i, 15) + Cells(i, 17)
Cells(i, 19) = Cells(i, 11) * Cells(i, 12) + Cells(i, 13) * Cells(i, 14) + _
Cells(i, 15) * Cells(i, 16) + Cells(i, 17) * Cells(i, 182)
End If
End Sub