Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It seems (see previous discussion) that the function "redim" is much
faster than going through a loop to reset an array to its initial value. I was wondering if there was a similar "smart" way to add two arrays together, ie doing something like X=ZeSmartFunction(X,Y) instead of for i = 1 to n X(i)=X(i)+Y(i) next i |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Redim sets the array's elements to blank. You don't want to set it to blank,
so you'll have to add the values together to generate new non-blank values. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "Charles" wrote in message ups.com... It seems (see previous discussion) that the function "redim" is much faster than going through a loop to reset an array to its initial value. I was wondering if there was a similar "smart" way to add two arrays together, ie doing something like X=ZeSmartFunction(X,Y) instead of for i = 1 to n X(i)=X(i)+Y(i) next i |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jon Peltier wrote:
Redim sets the array's elements to blank. . . . No. If the array type is String(), it resets them to blank. But, e.g., if the array type is Boolean(), it resets them to False; and if the array type is Integer() or Double(), iit resets them to 0. Alan Beban |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Duh, I was trying to differentiate between default values, which Alan has
clarified, and "initial" values, which may not be the default values, depending on how the user has initialized the array. Unfortunately I rushed through my response. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "Alan Beban" wrote in message ... Jon Peltier wrote: Redim sets the array's elements to blank. . . . No. If the array type is String(), it resets them to blank. But, e.g., if the array type is Boolean(), it resets them to False; and if the array type is Integer() or Double(), iit resets them to 0. Alan Beban |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks. Actually I was mostly interested in a way to add two arrays. I
haven't found anything on google nor in VBA's help. I guess there is no faster way to add two arrays together than to go through every single element with a loop. Charles |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There might be easier ways, but not faster ways, if you have access to
functions that do the hard work in the function and you only see the function call: NewArray = SumArrays(Array1, Array2) I'm sure there are slower ways. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "Charles" wrote in message oups.com... Thanks. Actually I was mostly interested in a way to add two arrays. I haven't found anything on google nor in VBA's help. I guess there is no faster way to add two arrays together than to go through every single element with a loop. Charles |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Fast export large 2-dim array to worksheet | Excel Programming | |||
Need help fast! | Excel Discussion (Misc queries) | |||
need help fast! | Excel Programming | |||
range to VBA array, and doing this fast | Excel Programming | |||
Remove First Row from Variant Array FAST? | Excel Programming |