åèï¼
Sub SumCalculation()
Dim FirstRow As Long, LastRow As Long
Dim MyCpt As Long
Dim F As Range
Dim I As Long
Dim MyFormula As String
Application.ScreenUpdating = False
FirstRow = 2
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range(Cells(FirstRow, "B"), Cells(LastRow, "B")).ClearContents
For I = FirstRow To LastRow
If (Cells(I, "A") <> "") Then
MyFormula = "COUNTIF(A" & FirstRow & ":A" & I & ",A" & I & ")"
MyCpt = Evaluate(MyFormula)
If (MyCpt = 1) Then
MyFormula = "SUMPRODUCT((A" & FirstRow & ":A" & LastRow & "=A" & I & ")*(C" & FirstRow & ":C" & LastRow & "))"
Cells(I, "B") = Evaluate(MyFormula)
End If
End If
Next I
Application.ScreenUpdating = True
End Sub
温馨提示:答案为网友推荐,仅供参考