ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Arithmatic operation on arrays (https://www.excelbanter.com/excel-programming/320572-arithmatic-operation-arrays.html)

Jeff

Arithmatic operation on arrays
 
This one has to have been asked before,

I have two arrays

AAA(100), BBB(100) filled with 100 numbers,

How do I add each element in each array to each other

AAA(100) = AAA(100)+BBB(100)
so
AAA(100) = a1+b1, a2+b2, ..., a100+b100


Thanks for your help!

Norman Jones

Arithmatic operation on arrays
 
Hi Jeff,

I think that it would be necessary to loop through the two arrays, e.g.:

ArrA = ActiveSheet.Range("A1:A100").Value
ArrB = ActiveSheet.Range("B1:B100").Value

ReDim ArrC(1 To 100)

For iCtr = 1 To 100
ArrC(i) = ArrA(iCtr, 1) + ArrB(iCtr, 1)
Next i

Range("C1").Resize(100) = Application.Transpose(ArrC)


---
Regards,
Norman



"Jeff" wrote in message
...
This one has to have been asked before,

I have two arrays

AAA(100), BBB(100) filled with 100 numbers,

How do I add each element in each array to each other

AAA(100) = AAA(100)+BBB(100)
so
AAA(100) = a1+b1, a2+b2, ..., a100+b100


Thanks for your help!





All times are GMT +1. The time now is 01:18 AM.

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