+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    11-17-2005
    Location
    Georgia
    Posts
    78

    Working with Array Data

    I have a macro that manipulates a rather large amount of date. To speed up the process, I use a 2 dimensional array loaded from the data on an excel sheet rather than manipulating the data directly in the excel sheet. After all calculations are complete, I then write back the entire chunk of data to the worksheet.

    All of this works great, and it does speed up calculations....

    There are a few "columns" of data that are not needed on the final output, and there are some "rows" that need to be deleted as well. Currently I am writing the entire array back to the excel sheet and another subroutine goes through and cleans up the data (deletes selected columns and rows)

    My question is: Is there a way to delete this un-needed data while it is still in an array (effectively resizing the array - removing specific columns and rows) and then writing the array back to the worksheet?

    Example:
    (5X5) Array with the following data

    Code:
    A A X A A
    B B X B B
    X X X X X
    D D X D D
    E E X E E
    Delete Column 3 and Row 3 Leaving
    Code:
    A A A A
    B B B B
    D D D D
    E E E E
    And writing that back to the worksheet

    The main reason I am asking is curiosity - my subroutines function fine as is, but I just cant seem to leave them alone - always tweaking and trying to be more efficient.

    TIA for any comments

    -Lee
    Last edited by tekman; 09-25-2009 at 09:03 AM.

  2. #2
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,134

    Re: Working with Array Data

    You would have to copy the array down over the replaced row, and then resize the array (Redim Preserve ...). Whether that's faster is something you could determine experimentally.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Working with Array Data

    I was always under the impression you could not ReDim Preserve a multi dimensional array, or rather you could only ever ReDim Preserve the final dimension of said array. Not something I know much about mind you...

  4. #4
    Registered User
    Join Date
    11-17-2005
    Location
    Georgia
    Posts
    78

    Re: Working with Array Data

    Thanks for the reply's

    You confirmed my suspicions, I just wanted to run it by the experts before I gave up on the idea

    -Lee

Thread Information

Users Browsing this Thread

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

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.2.0