Sum up Cell Values

jerryg72

New Member
Joined
Dec 30, 2005
Messages
40
I'm new to this forum and it seems very much helpful for an intermediate like me on excel. I've got a question for you excel experts. I would like to know if you could add the cell values when I type in new digits. For Example. if A1 is 136 and when I type in 10 in A1 (same cell) is there any way (formula, macros or vba scripts) that the Value of A1 change to 146? All the help and assistance in this matter would be highly appreciated. :cool:
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Try this for the sheet you want this to happen on:

Code:
Public x

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
If Target = "" Then
    x = 0
    Exit Sub
End If
Application.EnableEvents = False
    Target = Target + x
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Address = "$A$1" Then x = Target
End Sub
 

jerryg72

New Member
Joined
Dec 30, 2005
Messages
40
Thank you very much hotpepper, thats exactly what I wanted. I appreciate your quick response. One more quick question, what if I need this in more than one cell?
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
How many cells and which ones exactly?
 

jerryg72

New Member
Joined
Dec 30, 2005
Messages
40

ADVERTISEMENT

I told A1 as an example, but in real I need this in d3 thru d6, then d8, d10, d12, d14, d16, d18, d20, d22, d24, and d29 thru d32. Thanks for your assistance again.
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Give this a try:

Code:
Public x
Public r As Range

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, r) Is Nothing Then Exit Sub
If Target = "" Then
    x = 0
    Exit Sub
End If
Application.EnableEvents = False
    Target = Target + x
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If r Is Nothing Then _
    Set r = Union(Range("D3:D6"), Range("D8"), Range("D10"), Range("D12"), _
        Range("D14"), Range("D16"), Range("D18"), Range("D20"), Range("D22"), _
        Range("D24"), Range("D29:D32"))
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, r) Is Nothing Then x = Target
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,119,128
Messages
5,576,251
Members
412,709
Latest member
Rishu
Top