+ Reply to Thread
Results 1 to 5 of 5

Create class module that when instantiated creates a tab from an array of db values?

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    aitryze years,
    MS-Off Ver
    excel 2010
    Posts
    7

    Create class module that when instantiated creates a tab from an array of db values?

    Right now, I have a vba application that draws a tab based on a series of values that are already in memory. It works just fine, however, the act of creating the tabs from the aforementioned MDX queries is not as fast as I think it could be if it were a class object .

    Is there an effective manner to create a class module that creates a worksheet when instantiated and assigns values/formulas ? How does this work? It seems like it should be faster.. but that is why I am asking.

    If it is, how do I approach this?

    I have experience in c++/java from way back in object orientated programming but I am rusty.

    Right now the tab creation and drawing process takes about 2 seconds per tab and is 76R by 29C. I would like to cut that in half or less.

    To recap, the goal is to do the following:

    1. Associate and apply values from a 3 dimensional array to a class object
    2. Class object instantiation results in creation of new, named workbook tab
    3. Do it fast

    Thanks

    Also, I have searched extensively and I am just not finding anything from which I can build.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Create class module that when instantiated creates a tab from an array of db values?

    Hello fmaa,

    Rather than use a Class, you should create a single sheet in the workbook or import it from another to be used as template. This worksheet would already have the formats, shapes, colors, etc. on it. Copying a worksheet as a complete object is much faster than building it piece by piece. After the worksheet is imported you can copy the formulas and data to it using VBA.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    09-05-2012
    Location
    aitryze years,
    MS-Off Ver
    excel 2010
    Posts
    7

    Re: Create class module that when instantiated creates a tab from an array of db values?

    That is actually what I started with as far as all of the labels. The values are actually dynamically queried via MDX so they have to be written at some point.

    Thanks for the input.


    Here is what I ended up doing today.....


    1. Write a hard coded array of the side/top labels since these never change
    2. Created a class file object for just the individual reporting unit
    3. Indexed the reporting units by hierarchy in a collection
    4. Store an entire 4d array across 24m of data into 1 variant array in the class file
    5. Have Collection in memory at runtime based on user input ready to write object values

    It is WAY faster than before. The act of iteratively computing then writing values on a per reporting unit subset of the collection was insanely slow versus this.

    For i, for j, for z, for l.... write value from a preindexed, dimensional flat file vs just 2 nested loops of preloaded, preindexed values from a class object

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Create class module that when instantiated creates a tab from an array of db values?

    Hello fmaa,

    Good to know you have it sorted out. Unless you need to copy formatting, it is always much, much faster to copy formulas or values into arrays and then copy them to the table.

  5. #5
    Registered User
    Join Date
    09-05-2012
    Location
    aitryze years,
    MS-Off Ver
    excel 2010
    Posts
    7

    Re: Create class module that when instantiated creates a tab from an array of db values?

    Yeah. Pretty obvious in hindsight I suppose.

+ 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. [SOLVED] Accessing array in a class module
    By chipnputt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-09-2014, 11:09 PM
  2. [SOLVED] Sorting an array of a specific class module
    By MartinaLucilla in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-30-2013, 11:07 AM
  3. [SOLVED] Class module / multidimensional array?
    By swoop99 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-09-2013, 09:31 AM
  4. create event in class module
    By x taol in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2006, 10:40 PM
  5. Create Class Module using late binding
    By Mariano B. in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2006, 03:25 PM

Tags for this Thread

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