+ Reply to Thread
Results 1 to 4 of 4

iterating and appending an array

  1. #1
    Registered User
    Join Date
    03-01-2019
    Location
    Mansfield
    MS-Off Ver
    2013
    Posts
    19

    iterating and appending an array

    Hi,

    i'm currently working on a simulation of population dynamics of a butterfly species. I have put in place all the code necessary for the simuation within a single season within an array, however, I now want to iterate the array for the number of seasons in question and append the array for year two under the array for year one and so on. A further complication is that the size of the array for year 2 is dependent on the sum of the number of eggs laid per butterfly (written in array 1). i'm not sure how to go about the code for this. I can't yet attach any files in the thread so i realise it's a little difficult nevertheless i was wondering if anyone has any suggestions?

    thanks in advance

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: iterating and appending an array

    To attach a file choose the Go Advanced button at the bottom of the post window area, look underneath the window for Manage Attachments and take it from there.

    To Add more data to a pre-existing array you'll need to redimension the array using the PRESERVE instruction. i.e.

    ReDim Preserve MyArray(x) ' where x is the new upper bound

    Not you can't use Redim an array if you originally Dimmed it as a static array, e.g. Dim MyArray(50)

    However upload the woprkbook and I'm sure we can move this on.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    03-01-2019
    Location
    Mansfield
    MS-Off Ver
    2013
    Posts
    19

    Re: iterating and appending an array

    oh okay! Thanks very much!
    workbook attached
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-01-2019
    Location
    Mansfield
    MS-Off Ver
    2013
    Posts
    19

    Re: iterating and appending an array

    for the code i was using a simple flowchart that i'm attaching now if that's of any use
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Error 10 - Locked Array while iterating through dictionaries
    By Pango in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2017, 03:54 PM
  2. DIMming / setting multiple ranges by iterating over an array of string elements
    By brownfox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-12-2013, 08:14 PM
  3. Iterating one array by another
    By Poolstick in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2013, 02:41 PM
  4. Iterating through values
    By thepopasmurf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2010, 01:44 PM
  5. iterating groups?
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2005, 07:05 AM
  6. [SOLVED] iterating checkboxes
    By [email protected] in forum Excel General
    Replies: 1
    Last Post: 05-11-2005, 04:06 PM
  7. appending array
    By schandran in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-23-2005, 06:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1