Forum Discussion

Bruce_Pahnl's avatar
Bruce_Pahnl
Copper Contributor
Jan 05, 2023

Excel

In excel we have just two cells. Enter a value in cell #1 and it's value is then added to the current value in cell #2. Then cell #1 is zeroed out, and the value in Cell#2 remains as is... Now enter a new value in cell#1, which then updates the value in cell#2, and thus cell #1 is again zeroed out, and cell #2 has a new value which keeps accumulating (for positive numbers)...Is this possible to do in excel without creating (over time) a huge list of numbers.....??????

  • Bruce_Pahnl 

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim rngBereich As Range
    
    Set rngBereich = Range("A1")
    
    If Not Application.Intersect(Target, rngBereich) Is Nothing Then
    
    Target.Offset(1).Value = Target.Offset(1).Value + Target.Value
    Target.Value = ""
    
    End If
    
    End Sub

    Maybe with these lines of code. In the attached file you can enter a number in cell A1 and cell A2 is updated accordingly.

    • PahnlKim's avatar
      PahnlKim
      Copper Contributor
      Thank you very much. Now to learn VBA. Be well.

Resources