+ Reply to Thread
Results 1 to 4 of 4

macro to Read Data Strings

  1. #1
    Registered User
    Join Date
    10-21-2010
    Location
    Akron,OH, USA
    MS-Off Ver
    Excel 2007
    Posts
    44

    macro to Read Data Strings

    I have written the macro below to read data string from text file. Can any one tell me where i did wrong? when i run this macro it says "Compile error: Expected array".
    Please help me with these code.
    Please Login or Register  to view this content.
    Last edited by mithil; 11-04-2010 at 03:23 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: macro to Read Data Strings

    Hi mithil,

    First - edit your post and then go to advanced. Put Code Tabs (the # icon above the message) and save. This will allow us to read your code much easier. Please do this first.

    Second a possible answer. Code like Record_Type(1) thinks Record_Type is a single dimension array. It thinks you are looking for a single element in the array. (Arrays default to zero base so the first thing in them is number zero) This may give you the first explaination.

    Third - Put above all your code int he Module "Option Base Explicit". This will keep the code from compiling without dimensioning your variables.

    Last - Arrays need to be dimensioned as Variant.

    Look here for examples http://www.cpearson.com/excel/VBAArrays.htm
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    10-21-2010
    Location
    Akron,OH, USA
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: macro to Read Data Strings

    Can you describe your second and third option with example,Please.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: macro to Read Data Strings

    OK - here is some code to put in your module. Then go down to the immediate window and type ShowMithil and press enter. See if this helps..
    Please Login or Register  to view this content.

+ Reply to Thread

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.6.0 RC 1