ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add a value to itself (https://www.excelbanter.com/excel-programming/356903-add-value-itself.html)

MABeatty[_2_]

Add a value to itself
 

First of all please forgive me for my lack of experience
I am good with excel, and good with vb, but am new to using vb i
excel

What I am looking to do is take a row of cells (Row A) and add them t
another row (Row B) and place it in Row B

Basically:
("A1:A20") + ("B1:B20") = ("B1:B20")

I'm assuming I will need a FOR EACH loop, but I'm not familar with th
correct synta

--
MABeatt
-----------------------------------------------------------------------
MABeatty's Profile: http://www.excelforum.com/member.php...fo&userid=3225
View this thread: http://www.excelforum.com/showthread.php?threadid=52567


Simon Lloyd[_707_]

Add a value to itself
 

Hi, I recorded this, i put values in cells A1:A10 and values in B1:B10
then highlighted cells C1:C10 then clicked on the sum icon and below is
the code it produced......it should get you somewhere near to want you
are trying to do.

regards,

Simon
Sub count()
Range("C1:C10").Select
Selection.FormulaR1C1 = "=SUM(RC[-2]:RC[-1])"
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=525672


Martin

Add a value to itself
 
Here's one way (could also do it with a For...Next loop of course):

Sub AddAB()
Dim myCell As Range
For Each myCell In Range(Cells(2, 1), Cells(2, 20))
myCell.Value = myCell.Value + myCell.Offset(-1, 0).Value
Next
End Sub

"MABeatty" wrote:


First of all please forgive me for my lack of experience
I am good with excel, and good with vb, but am new to using vb in
excel

What I am looking to do is take a row of cells (Row A) and add them to
another row (Row B) and place it in Row B

Basically:
("A1:A20") + ("B1:B20") = ("B1:B20")

I'm assuming I will need a FOR EACH loop, but I'm not familar with the
correct syntax


--
MABeatty
------------------------------------------------------------------------
MABeatty's Profile: http://www.excelforum.com/member.php...o&userid=32258
View this thread: http://www.excelforum.com/showthread...hreadid=525672



Tom Ogilvy

Add a value to itself
 
Sub AA()
Range("A1:A20").Copy
Range("B1:B20").PasteSpecial xlValues, xlAdd
End Sub


--
Regards,
Tom Ogilvy


"MABeatty" wrote:


First of all please forgive me for my lack of experience
I am good with excel, and good with vb, but am new to using vb in
excel

What I am looking to do is take a row of cells (Row A) and add them to
another row (Row B) and place it in Row B

Basically:
("A1:A20") + ("B1:B20") = ("B1:B20")

I'm assuming I will need a FOR EACH loop, but I'm not familar with the
correct syntax


--
MABeatty
------------------------------------------------------------------------
MABeatty's Profile: http://www.excelforum.com/member.php...o&userid=32258
View this thread: http://www.excelforum.com/showthread...hreadid=525672




All times are GMT +1. The time now is 08:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com