• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Best way to clear DATA from an array while preserving all other attributes of said array?

Status
Not open for further replies.

polarisking

Member
When I use ERASE in the forms of:

Erase arrTest, or
Erase arrTest()

the entire array structure is obliterated: the dimensions are gone, it looks just like another variable.

Right now, I'm looping through the dimensions and setting the values to whatever fits (0, "", etc.)

Any ideas? Thanks in advance.
 
You can redim the arr using its own ubounds:

redim arrTest(ubound(arrTest,1),ubound(arrTest,2))

nb: you use "redim preserve" ... to maintain the existing data.
 
You can redim the arr using its own ubounds:

redim arrTest(ubound(arrTest,1),ubound(arrTest,2))

nb: you use "redim preserve" ... to maintain the existing data.

This is helpful. I was hoping there'd be a single command driven statemente (like ERASE) that would do the same thing. Certainly the advantage of your suggestion is using the Upper Bounds values.
 
As it depends on how the variable is declared - so easy to read the Dim VBA help explanation ! - but again you forgot to share your code …​
 
As it depends on how the variable is declared - so easy to read the Dim VBA help explanation ! - but again you forgot to share your code …​

Marc L, I think you may have helped me in the past. I'm not sure how to interpret your response.
 
You forgot to share all your code and as the answer is already within the VBA help for Dim​
or better for Erase itself (a must see : the Erase sample).​
So according to this kid level reading for a dynamic array all is reset ! Which is not the case for a non dynamic array …​
 
Nice of you to share Marc, of course you could have answered the question in a single brief response rather than attacking the OP for insulting your profound intellect. Are you a mod here or do the actual mods just let people get away with anything in general?
 
Ok Kid, no intention to insult anyone but to remind the 'good rules' of any forum​
as it is far better for the initial poster to share his code rather than a single statement​
'cause like you should know an easy workaround exist !​
As a reminder a must read in this forum rules : how to get the best result.​
And thus without any link with the moderator 'status' …​
For new members the rules may be reminded but for old ones who each time do not well elaborate their threads​
yes sometimes they may not receive any help 'cause helpers are fed up.​
 
Status
Not open for further replies.
Back
Top