Adding ranges within VBA


Posted by duncan on December 14, 2001 8:16 AM

I have two ranges say A1:A4 and B1:B4 (actually lrger than this and multiple types)
and wish to enter in C1:C4 A1:A4 + B1:B4.
However it must be within the code and not a formula on the sheet as there are a large number of these (365 infact) and if there are formulae the Workbook gets very large.
Looping through the cells individually seems to take a long time as well!
If anyone knows how to do it (preferably with Paste Specials) then that would be great.

D.



Posted by Juan Pablo G. on December 14, 2001 3:24 PM

I can't be more specific since i don't know what you're trying to do, but this will do for your example.

Range("C1:C4") = Evaluate("A1:A4+B1:B4")

Evaluate treats all functions as Array functions (I think...)

Juan Pablo G.