Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"