|
Sub Test_A1() '\\by.准提部林
Dim xA As Range, Arr, Brr, i&, j%, k%, v1, v2, v, P
Set xA = Range(Cells(Rows.Count, "d").End(3)(1, 2), Cells(5, Columns.Count).End(1)(2))
Arr = xA.Value: Brr = Arr
For i = 1 To UBound(Arr) Step 3
For j = 1 To UBound(Arr, 2)
If Arr(i, j) <> 0 Then
For k = 1 To UBound(Arr, 2)
If Arr(i + 1, k) = Arr(i, j) Then Arr(i, j) = 0: Arr(i + 1, k) = 0: Exit For
Next k
End If
Next j
Next i
'-----------------------
For i = 1 To UBound(Arr) Step 3
k = 0
For j = UBound(Arr, 2) To 1 Step -1
Brr(i + 2, j) = ""
v1 = Val(Arr(i, j)): v2 = Val(Arr(i + 1, j))
If v1 <> 0 Or v2 <> 0 Then k = j
v = v1 - v2: P = P + v
If v > 0 And P > 0 Then Brr(i + 2, j) = P: P = 0
Next j
If k = 0 Then k = 1
If P <> 0 Then Brr(i + 2, k) = P: P = 0
Next i
'------------------------
xA = Brr
End Sub
|
评分
-
1
查看全部评分
-
|