Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
George
 
Posts: n/a
Default VBA: sum two named ranges, cell-by-cell

If I have x = A1:A4, y= B1:B4, z = C1:C4. Is there a way in a VBA script to do
z[i] = x[i] + y[i]?

Thanks,
George
  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default sum two named ranges, cell-by-cell

George,

Try some code like the following:

Dim Ndx As Long
Dim Result As Double
For Ndx = 1 To Range("X").Rows.Count
Result = Range("X")(Ndx) + Range("Y")(Ndx) + Range("Z")(Ndx)
Debug.Print Result
Next Ndx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"George" wrote in
message ...
If I have x = A1:A4, y= B1:B4, z = C1:C4. Is there a way in a
VBA script to do
z[i] = x[i] + y[i]?

Thanks,
George



  #3   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default sum two named ranges, cell-by-cell

George,

I misread your post. Try the following code instead.

Dim Ndx As Long
For Ndx = 1 To Range("X").Rows.Count
Range("Z")(Ndx) = Range("X")(Ndx) + Range("Y")(Ndx)
Next Ndx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Chip Pearson" wrote in message
...
George,

Try some code like the following:

Dim Ndx As Long
Dim Result As Double
For Ndx = 1 To Range("X").Rows.Count
Result = Range("X")(Ndx) + Range("Y")(Ndx) + Range("Z")(Ndx)
Debug.Print Result
Next Ndx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"George" wrote in
message ...
If I have x = A1:A4, y= B1:B4, z = C1:C4. Is there a way in a
VBA script to do
z[i] = x[i] + y[i]?

Thanks,
George





  #4   Report Post  
Posted to microsoft.public.excel.misc
George
 
Posts: n/a
Default sum two named ranges, cell-by-cell

On Fri, 28 Apr 2006 16:21:14 -0500, "Chip Pearson" wrote:

George,

I misread your post. Try the following code instead.

Dim Ndx As Long
For Ndx = 1 To Range("X").Rows.Count
Range("Z")(Ndx) = Range("X")(Ndx) + Range("Y")(Ndx)
Next Ndx


That's nice - thank you.

George
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically building references to named ranges [email protected] Excel Discussion (Misc queries) 1 January 3rd 06 10:23 PM
help with inserting a cell value into a named formula Ed Excel Discussion (Misc queries) 1 November 25th 05 10:14 PM
Replace a spreadsheets named cells/ranges with exact cell address. David McRitchie Excel Discussion (Misc queries) 0 September 28th 05 08:59 PM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
Named Cell Ranges Blackcat Excel Discussion (Misc queries) 1 December 9th 04 09:57 AM


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

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

About Us

"It's about Microsoft Excel"