HOW DO I ADD ONE COLUMN TO A SECOND WITHOUT DELETING THAT VALUE

N

Nick

How do I add one column to a second without deleting the original value in
the second column. i am trying to get an accumulative value. The value in
the first column will change constantly.

Thanks,

Nick
 
J

JP

Can't you use a third column and just add the two values together, or
am I missing something?

Column 3 = Column 1 + Column 2

ex:

A1 contains the number 1
B1 contains the number 2
C1 contains "=A1+B1"

HTH,
JP
 
B

Barb Reinhardt

You'll need a worksheet_change event on the worksheet of interest. Right
click on the worksheet tab to View Code. Select the worksheet you are
changing and paste this in for the code

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myChangeRange As Range
Dim myChangeRangeCol As Long
Dim myAccumRangeCol As Long

myChangeRangeCol = 2 'Column B, Change as needed
myAccumRangeCol = 3 'Column C

Set myChangeRange = Me.Columns(myChangeRangeCol)

If Target.Count > 1 Then Exit Sub

If Not Intersect(myChangeRange, Target) Is Nothing Then
Target.Offset(0, myAccumRangeCol - myChangeRangeCol).Value = _
Target.Offset(0, myAccumRangeCol - myChangeRangeCol).Value + _
Target.Value
End If

End Sub
 
B

Barb Reinhardt

It works in 2003 as well. Do you have your speakers on? What references do
you have set for your project?
 
G

Gary Keramidas

i have no idea what you're trying to do, but here's a guess.

Sub test()
Dim ws As Worksheet
Dim lastrow As Long
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
Dim i As Long

For i = 1 To lastrow
With ws
.Range("B" & i).Formula = "=" & .Range("B" & i).Value & "+ A" & i
End With
Next
End Sub
 
Top