+ Reply to Thread
Results 1 to 5 of 5

Variable dimension arrays?

  1. #1
    Registered User
    Join Date
    11-29-2012
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2010 (Excel, Word, Access)
    Posts
    72

    Variable dimension arrays?

    Okay, I'm feeling like a Class A moron here, but hopefully there's some extra quirk here that I'm missing.

    We're putting in a new ERP, and in the course of testing we need to be able to compare outgoing payment files with the receipt files we get back from central processing. I'm trying to take a text file that includes numerous payment batches and convert them into the payment-by-payment data in that receipt file.

    Record 1: Header Information.
    Record 2: Payee Data
    Record 3: Accounting Info
    Record 4: Payment Message
    Record 5: Ad Hoc Payee Data (Optional Record)
    Record 99: Batch Data

    Each outgoing file includes one 99 record.
    Each 99 record can include multiple 1 records. There is a matching 4 record for each 1 record, and possibly a 5 record to go with them.
    Each 1 record can include multiple 2 records.

    The 3 records don't really matter, since that's not in the return file.

    Since I need a line in my "dummy" return file for each 2 record, I'm trying to use arrays to pull together all of my information and then reconstitute it in line-by-line form. The problem I'm running into is that the batch files can be various lengths and having various numbers of each record... and, more importantly, I can't figure out how to add the new values into what should be an empty array.

    Basically, when I try adding the info, it's popping various different types of error. I've figured out that the .Add method doesn't work, but I'm also running into trouble with just adding them as values. These are the examples of how I'm structuring the addition at this point:

    Please Login or Register  to view this content.
    intMark99 is, obviously, an integer being used as my index. Is it the fact that my arrays were all declared with undefined dimensions? Or am I just using entirely the wrong code?

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Variable dimension arrays?

    Put a break in the macro.

    In visual basic select your code and press. F9

    When the macro halts select views local window

    Then look at your array. I suspect your array numbering starts at 0 and you are assuming it starts at 1.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    03-26-2014
    Location
    Nowhere, somewhere
    MS-Off Ver
    Excel 2007
    Posts
    75

    Re: Variable dimension arrays?

    Quote Originally Posted by JasonLeisemann View Post
    Is it the fact that my arrays were all declared with undefined dimensions? Or am I just using entirely the wrong code?
    Initially undefined dimensions are fine, but at some point you have to give it a definition. If you do not have a ReDim statement somewhere in there, then yes you are doing it wrong.
    Last edited by TnTinMN; 05-11-2015 at 02:33 PM. Reason: typo

  4. #4
    Registered User
    Join Date
    11-29-2012
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2010 (Excel, Word, Access)
    Posts
    72

    Re: Variable dimension arrays?

    Turns out that it was the lack of a ReDim... at least the first time around.

    Next question - when I ReDim an array, does it empty everything if I forget the Preserve argument? Because I literally just realized that might be why I'm returning empty arguments when I try to pull my
    populated array data.

    Thanks for the help from both of you!

  5. #5
    Registered User
    Join Date
    03-26-2014
    Location
    Nowhere, somewhere
    MS-Off Ver
    Excel 2007
    Posts
    75

    Re: Variable dimension arrays?

    Quote Originally Posted by JasonLeisemann View Post
    when I ReDim an array, does it empty everything if I forget the Preserve argument?
    Preserve is necessary to retain the existing values.

+ 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] Need to properly dimension and define variable range for use in CountIf
    By under00c in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-08-2013, 09:52 AM
  2. Variable Arrays
    By learning excelcode in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2010, 06:15 PM
  3. Multi Variable Arrays with And & Or
    By coinbank in forum Excel General
    Replies: 3
    Last Post: 01-12-2010, 08:22 PM
  4. adding variable arrays
    By soce in forum Excel General
    Replies: 8
    Last Post: 10-18-2007, 04:05 PM
  5. vlookup usage with dynamic & multi dimension arrays
    By pjjclark in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2007, 04:02 AM

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