How does VBA Store Arrays

chazz

Board Regular
Joined
Jul 24, 2006
Messages
70
I put an array in my code last night. Then I noticed that, after I shut Excel down an restarted it, the array values had not been lost.

Is the array stored in permanent memory? I didn't try shutting the machine down, to see if it survived that.

??
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Can you post the code?

I'm actually rather suprised that this happened.
 
Upvote 0
Dim pwe(10) As Variant

For x = 0 To 9
If Rnd > 0.5 Then pwe(x) = alphagen Else pwe(x) = numbergen
Next x

releasecode = pwe(0) & pwe(1) & pwe(2) & pwe(3) & pwe(4) & pwe(5) & pwe(6) & pwe(7) & pwe(8) & pwe(9)

So, when I call releasecode after exiting Excel and restarting it, I get the same value.

I had to put in a loop to clear the array in order to prevent that.

However, if the array normally stores in permanent memory, that would assist me in the app.
 
Upvote 0
Thanks.

Actually the routine raised the question about how ARRAYS store DATA, whether somewhere in permament memory or not --and that is what my post is about.
 
Upvote 0
Then I think you need to do one of two


1) store data in somewhere in the sheet before save
2) store data in registry
 
Upvote 0
Thank you.

Can someone please tell me where and how an ARRAY stores data?

Thanks.
 
Upvote 0
Thanks.

Actually the routine raised the question about how ARRAYS store DATA, whether somewhere in permament memory or not --and that is what my post is about.

It is not permanent.

It will be cleared from the memory when the routine finshes unless declared as a global variable.

Rnd function returns the same when you refresh it without Randomize statement.
 
Upvote 0
This has nothing to do with how an array is stored.
 
Upvote 0
You have used a same seed to make random numbers.

if you want to store an array,Use a range of worksheet to store it.

Best Regards
 
Upvote 0

Forum statistics

Threads
1,213,520
Messages
6,114,099
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top