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

  • Thread starter Thread starter Nick
  • Start date Start date
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
 
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
 
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
 
It works in 2003 as well. Do you have your speakers on? What references do
you have set for your project?
 
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
 
This reply was posted to the wrong thread. oops!

Barb Reinhardt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top