|
最终代码:
Sub xunhuan()
Dim i, s As Integer
For i = 6 To 15
s = Range("G" & i)
Range(Cells(i, 8), Cells(i, 8 - 1 + s)) = Range("F" & i)
If Range("E" & i) > Application.WorksheetFunction.Sum(Range(Cells(i, 8), Cells(i, 8 - 1 + s))) Then
Cells(i, 8 + s) = Range("E" & i) - Application.WorksheetFunction.Sum(Range(Cells(i, 8), Cells(i, 8 - 1 + s)))
End If
If Range("E" & i) < Application.WorksheetFunction.Sum(Range(Cells(i, 8), Cells(i, 8 - 1 + s))) Then
Cells(i, 8 - 1 + s) = Range("E" & i) - Application.WorksheetFunction.Sum(Range(Cells(i, 8), Cells(i, 8 - 2 + s)))
End If
Next
End Sub
|
|