+ Reply to Thread
Results 1 to 3 of 3

Creating Arrays in VBA

  1. #1
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Creating Arrays in VBA

    Static / Fixed Arrays

    These are manually dimensionalized. Dimensions and number of elements are defined manually when arrays are declared. For example:
    Please Login or Register  to view this content.
    These have to be populated from their declaration specs. For example:
    Please Login or Register  to view this content.
    Dynamic Arrays

    These are unspecified in terms of dimensions and number of elements. Example:
    Please Login or Register  to view this content.
    These have to be redimensionalized every time an element or a dimension is added. The ReDim statement is used for this. Using ReDim alone will empty the area every time it is redimensionalized so you have to populate it afterwards. Use this on arrays with more than one dimension. For example:
    Please Login or Register  to view this content.
    Using ReDim Preserve saves the values that are already in the array and also redimensionalizes it. It saves time for one-dimensionals, like:
    Please Login or Register  to view this content.
    More than one dimension usually does not work with Preserve because the last dimension must not be manipulated when using the key word.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Creating Arrays in VBA

    Your redim example may make more sense if you included an array variable,
    Please Login or Register  to view this content.

    And ReDim Preserve can be used with multi dimensional arrays but will only allow you to resize the final element.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Creating Arrays in VBA

    good deal Andy. the post was something I wrote years ago. It has never been reviewed. anyone and everyone should add to this if it makes sense.

+ 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. Creating Charts from Arrays
    By ptmuldoon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-12-2019, 10:59 AM
  2. [SOLVED] Creating arrays to use in SUMIFS
    By cmcgath in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-23-2014, 01:53 PM
  3. [SOLVED] Creating arrays to use in SUMIFS
    By cmcgath in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-22-2014, 12:19 PM
  4. Help with creating Arrays. thanks!
    By florayaoyao in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2014, 03:26 PM
  5. Creating a xlBarStacked chart from arrays on with VBA
    By dherrero in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-23-2014, 08:40 AM
  6. Creating a list without arrays.
    By darq in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-10-2014, 06:12 AM
  7. Creating arrays from multiple worksheets
    By ashuperstar in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-18-2013, 12:58 PM

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