答:編程壹步完成
按ALT+F11組合鍵,打開VB窗口,執行"插入"-"模塊",復制下面代碼進去,按F5運行程序即得到結果。
Sub?Demo()Dim?LastRow?As?Long
Dim?i?As?Long
Dim?TempArr?As?Variant
With?CreateObject("scripting.dictionary")
LastRow?=?Cells(Rows.Count,?1).End(xlUp).Row
For?i?=?1?To?LastRow
TempArr?=?Split(Cells(i,?1),?"+")
If?Not?.exists(TempArr(0))?Then
.Item(TempArr(0))?=?TempArr(1)
Else
.Item(TempArr(0))?=?Val(.Item(TempArr(0)))?+?Val(TempArr(1))
End?If
Next
For?i?=?1?To?50
If?Not?.exists(CStr(i))?Then
Cells(i,?3)?=?i
Cells(i,?4)?=?0
Else
Cells(i,?3)?=?i
Cells(i,?4)?=?.Item(CStr(i))
End?If
Next
End?With
End?Sub