Sub chuyen()
Dim a As Long, b As Long, c As Double, i As Long, j As Long, d As Double, lr As Long
Dim arr, arr1
Dim dic As Object
Dim dk As String
Set dic = CreateObject("SCripting.dictionary")
With Sheet1
b = .Range("A" & Rows.Count).End(xlUp).Row
arr = .Range("A1:G" & b).Value
ReDim arr1(1 To UBound(arr, 1), 1 To 7)
For i = 1 To UBound(arr, 1)
For j = 1 To 7
arr1(i, j) = arr(i, j)
Next j
If IsNumeric(arr(i, 2)) = True And a = 0 And arr(i, 1) = "TARGETL" Then
b = i
a = 1
c = arr(i, 2)
End If
If arr(i, 1) = "TARGETR" And a = 1 Then
a = 0
d = (c - arr(i, 2)) / 2
arr1(i, 2) = -d
arr1(b, 2) = d
End If
Next i
lr = .Range("r" & Rows.Count).End(xlUp).Row
.Range("P1").Resize(lr, 7).ClearContents
.Range("R1").Resize(UBound(arr, 1), 7).Value = arr1
End With