Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A5:A13")) Is Nothing Then
Dim jJ As Byte: Dim MyAdd As String, TangDT As String
Dim Sh As Worksheet, Rng As Range, sRng As Range
Dim Clls As Range, Rng0 As Range
Set Sh = Sheets("Tinh Toan"): TangDT = Sh.Range("TangDTV").Value
Set Rng = Sh.Range(Sh.[B7], Sh.[B65500].End(xlUp))
Set sRng = Rng.Find(TangDT, , xlFormulas, xlWhole)
If Not sRng Is Nothing Then
MyAdd = sRng.Address
Do
jJ = jJ + 1
If jJ = Target.Value Then
Set Rng0 = sRng.Offset(-5).Resize(30): Exit Do
End If
Set sRng = Rng.FindNext(sRng)
Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
End If
MsgBox Rng0.Address
For Each Clls In Rng0
If InStr(Clls.Value, "DT V") > 0 Then
Target.Offset(, 2).Value = Clls.Offset(, 1).Value
Target.Offset(, 1).Value = Clls.Offset(-2, 1).Value
ElseIf InStr(Clls.Value, "DT CHN:") > 0 Then
Target.Offset(, 3).Value = Clls.Offset(, 1).Value
ElseIf InStr(Clls.Value, "TH DA") > 0 Then
Target.Offset(, 4).Value = Clls.Offset(, 1).Value
ElseIf InStr(Clls.Value, "TH ") > 0 And InStr(Clls.Value, "TH D") = 0 Then
Target.Offset(, 5).Value = Clls.Offset(, 1).Value
ElseIf InStr(Clls.Value, "AAA:") > 0 Then
Target.Offset(, 8).Value = Clls.Offset(, 6).Value
ElseIf InStr(Clls.Value, "BBB:") > 0 Then
Target.Offset(, 9).Value = Clls.Offset(, 6).Value
ElseIf InStr(Clls.Value, "zz") > 0 Then
Target.Offset(, 10).Value = Clls.Offset(, 6).Value
ElseIf InStr(Clls.Value, "aa ab") > 0 Then
Target.Offset(, 11).Value = Clls.Offset(, 6).Value
ElseIf InStr(Clls.Value, "ac ad") > 0 Then
Target.Offset(, 12).Value = Clls.Offset(, 6).Value
End If
Next Clls
End If
End Sub