+ Reply to Thread
Results 1 to 4 of 4

Redim preserve two dimensional array problem

  1. #1
    Registered User
    Join Date
    04-19-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    87

    Redim preserve two dimensional array problem

    Hi

    Im trying to place a row of data into an array if it contains a 2013 in the date cell.
    My problem is resizing the array to add a new row in the variant where the next data will go.

    The resize happens and i have Var(1) and var(2), but when
    the For loop runs for the next record, the second var (var(2)) is deleted! i tried using an integer eg var(i)
    and incrementing i through each loop but i keep getting a subscript out of range error! (second block of code)

    What is happening is, Var(1) is continously being overwritten, and Var(2) has "empty" in all its "cells".

    What am i missing?

    thanks

    Please Login or Register  to view this content.

    My attempt at including an incrementing integer



    Please Login or Register  to view this content.
    Last edited by wazimu13; 12-06-2013 at 06:53 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Redim preserve two dimensional array problem

    If you wanted to use that approach, try this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-19-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Redim preserve two dimensional array problem

    hi, Thanks StephenR. That worked, but i have another problem
    I would like to delete a row of data once ive added its data to the variant.
    I tried adding

    Please Login or Register  to view this content.
    right after "Next J, but when i run the code, it only deletes half the lines? ( 900 rows meet the criteria and only 450 are deleted).
    Does this have anything to do with where ive placed the code?

    thanks

  4. #4
    Registered User
    Join Date
    04-19-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Redim preserve two dimensional array problem

    I tried a few things with this today and i think i solved it

    Instead of the line
    Please Login or Register  to view this content.
    use this:

    Please Login or Register  to view this content.
    That way it adds the records and deletes the rows in reverse order!

    Thanks very much for your help StephenR (hands virtual pint!)

+ 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] Two dimensional array Redim preserve problem
    By wazimu13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2013, 04:44 AM
  2. Redim Preserve a multi-dimen. array.
    By david90 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-08-2012, 03:41 PM
  3. redim preserve multidimensional array
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-07-2011, 02:48 PM
  4. Redim 2 dimensional array
    By efernandes67 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-10-2011, 10:38 AM
  5. Redim Preserve 2D Array
    By kraljb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2006, 03:23 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