答案1
您需要为此添加大量错误检查,但这里只是基本内容:
Private Sub Worksheet_Change(ByVal Target As Range)
' If we're not in the range of interest
' do nothing.
If Intersect(Target, Me.Range("B2:E2")) Is Nothing Then
Exit Sub
End If
' We don't want this event to fire itself!
Application.EnableEvents = False
' Now add the row above (rowOffset = -1) to the value.
Target.Value = Target.Value + Target.Offset(-1, 0).Value
' Don't forget to re-enable events, otherwise there'll
' be no more VBA events fired.
Application.EnableEvents = True
End Sub