Private Sub Worksheet_Change(ByVal Target As Range)
Const sAdrInp As String = "A1" ' input cell, change as desired
Const sAdrOut As String = "B1" ' output cell, change as desired
With Target
If .Address(False, False) = sAdrInp Then
If VarType(.Value) = vbDouble Then
Me.Range(sAdrOut).Value = Me.Range(sAdrOut).Value + .Value
End If
End If
End With
End Sub
Put the code in the appropriate Sheet module:
Adding Code to a Sheet module
1. Copy the code from the post
2. Right-click on the tab for the relevant sheet and select View Code. This opens the Visual Basic Editor (VBE) and shows the object module for the selected worksheet.
3. Paste the code in the window
4. Press Alt+Q to close the VBE and return to Excel
EDIT: That Roy is fast!
Bookmarks