Dim i As Integer
Dim j As Integer
Dim k As Integer
Sheet3.Range("C4:C43").ClearContents '清空C4:C43区域
i = 2
Do While Sheet7.Cells(i, 3) <> ""
i = i + 1
Loop
j = 2 '源表,考虑表头1行
For j = 2 To i - 1 '有效行标为i-1,如果写为i会报错
k = 5 '目标表,考虑表头4行
Do While Sheet3.Cells(k, 1) <> ""
If Left(Right(Sheet7.Cells(j, 3), Len(Sheet7.Cells(j, 3)) - 8), Len(Right(Sheet7.Cells(j, 3), Len(Sheet7.Cells(j, 3)) - 8)) - 1) = Trim(Sheet3.Cells(k, 1)) Then
Sheet3.Cells(k, 3) = Abs(Val(Sheet7.Cells(j, 8)) - Val(Sheet7.Cells(j, 9)))
Exit Do
End If
k = k + 1
Loop
Next j