Closed Thread
Results 1 to 4 of 4

add class into dynamic array

  1. #1
    Registered User
    Join Date
    05-17-2020
    Location
    Beer sheeva , Israel
    MS-Off Ver
    10
    Posts
    17

    add class into dynamic array

    Hello friends, need your help please

    I have a class, and I need that as soon as the user clicks the button:

    1. A new class will be created and entered into a dynamic array.

    The array resizes each time the user presses the button.

    I just need some example of syntax how to do it.
    Thanks in advance

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: add class into dynamic array

    You may prefer using a Collection, but in either case, you will need to declare the array as a Public variable in a normal module, so it will not pass out of scope.

    Please Login or Register  to view this content.
    Note that this is for a 0-based array. And that much of the code is handling to deal with the case of the very first running of Test, where the Array hasn't been dimensioned yet.

    Another approach would be to have a fixed size array, larger than you will ever need, and use a companion public variable to indicate what the highest index being used is.

    Please Login or Register  to view this content.
    This works best with a 1-based array, since when you just start Excel, the value of ArrayElementCount is 0.

    The Collection approach is actualy simpler, because the start-up state is easier to detect and that code can be included in the class's Intialize event
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    05-17-2020
    Location
    Beer sheeva , Israel
    MS-Off Ver
    10
    Posts
    17

    Re: add class into dynamic array

    Thanks so much, something else I forgot to mention
    It is important that its array and values are preserved even after EXCEL closes
    Is the solution included?

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: add class into dynamic array

    Since this has same issue has been opened in the Commercial Services Forum, I am closing this thread. You cannot have more than one thread for the same issue open.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Populate Dynamic Array from Cell Values and write to Dynamic Range
    By TFiske in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2018, 09:09 AM
  2. “= 1st class’ lower class limit + class width"
    By CheeseFace in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2016, 08:21 PM
  3. Advice- Parent Class "Has a" Dynamic Number of Other Class
    By Kalithro in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-22-2016, 04:56 AM
  4. [SOLVED] Userform & Dynamic Controls & Class Module
    By sarndt01 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 09-18-2014, 01:53 PM
  5. [SOLVED] Property Get of a Class to return an Array
    By Rookie1982 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2013, 07:31 AM
  6. Dynamic 2 dimensional array in VBA class
    By dlx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2010, 09:20 PM
  7. class modules and array
    By Martin Bauer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2005, 09:40 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