Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

dynamic arrays

ResolvedVersion 2007

ALEX has attended:
Excel VBA Intro Intermediate course

Dynamic arrays

I am trying to use the "preserve Redim" command, in order to make use of dynamic arrays. Although I am sure that I am typing everything correctly since I am using one of the worked examples as a point of reference, my sub still does not preserve the existing content in my array and just simply overwrites all the inserted data every time. Is there a way of activating the "preserve" option somehow? Thanks

Edited on Wed 5 Sep 2012, 11:13

RE: Dynamic arrays

Hi Alex

Thanks for getting in touch. This one is tricky to diagnose without seeing the file you are working on. But in general Microsoft recommend that you phrase it e.g.

ReDim Preserve myArray(5) As Integer

Are you able to send over a copy of the file? My address is

gary@stl-training.co.uk

If that's not possible, even just the line you are using to declare that array initially, and then the line to redefine the array would be useful to know. In the meantime, here is a link to Microsoft's article on ReDimming:

http://msdn.microsoft.com/en-us/library/w8k3cys2 (v=vs.80).aspx

This article is for VB generally but can apply to Excel.

Kind regards

Gary
Microsoft Office Specialist Trainer

Will be marked as resolved in 5 days

Notice: This is an automated message. Due to inactivity, this forum post will be marked as 'resolved' if there are no further responses in the next 5 days.

Wed 19 Sep 2012: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Separate the year from a date

To separate the year from a date use the =year() function, eg a date is in cell A1 and in A2 you wish to display the year enter the function =year(A1)

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.