Hi,
As I read books and web posting about excel i have found something i would like to aska question about.
Dynamic Arrays:
What i have seen is that some people use the "ReDim Preserve" feature to size the array as needed while others simply "Oversize" the array initially then shrink it down.
i was wondering why you would "oversize" vs. "ReDim". Is there an advantage to one vs. the other that i dont know about? Is one faster if have lots of data?
It's better to minimize the number of times you use Preserve, so it should be quicker to overstate and then resize down.
You can also use collections as well
Collection could be indexed so searching could be fasterDim col As New Collection col.Add "value1", "key1" 'how to set value and key MsgBox col.Item(1) 'how to get value MsgBox col.Item("key1") ' -||-
Best Regards
Last edited by maczaq; 07-01-2011 at 09:29 AM.
what is "collection"? How does this work?
forgot to say thanks for the posts thus far..........really......learning alot from this site.
Look up Collection in the VBA Help.
You can also use the Scripting.Dictionary object which is more lightweight than the Collection and easier to get an array back out of.
@romperstomper
this Dictionary idea is great - I never see this before - thank You
for all users, you can read about Scripting.Dictionary object here:
http://www.kamath.com/tutorials/tut009_dictionary.asp
Best Regards
MaczaQ
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks