Macro that adds the number in on cell to another


Posted by Ben T on December 19, 2000 11:41 AM

How do I make a macro that adds the number in one cell to the number in the other cell without using a formula such as =9+1 etc, but instead the cell would just contain 10.

Cheers! Ben

Posted by Bruce on December 19, 2000 12:32 PM

Assume numbers in cells to add are to the left of destination cell. Select destination cell, and run this macro...

Sub AddCells()

ActiveCell.FormulaR1C1 = "=RC[-2]+RC[-1]"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
End Sub

Posted by Celia on December 19, 2000 4:56 PM


Alternatively :-

Range("C1").Value = Range("A1") + Range("B1")

Or :-

ActiveCell.Value = ActiveCell.Offset(0, -2) + ActiveCell.Offset(0, -1)



Posted by Bruce on December 19, 2000 6:20 PM

Thanks Celia, your suggestion is much better than mine. I have gotten many great pointers from you by reading this message board.
If I see a response from you, I make sure I read it, because I know it's going to be a good tip, and I'm going to learn something.
Thanks! :)