+ Reply to Thread
Results 1 to 10 of 10

strings and arrays

  1. #1
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    strings and arrays

    when I use the first myArray below this macro outputs a message box that tells me all the values I put into the array, however when I try to read some strings into the array from range A14 to A21 (sheetnames to look for), the code errors at the line: msgString = msgString & myArray(z) & vbCrLf


    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: strings and arrays

    Please Login or Register  to view this content.

  3. #3
    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: strings and arrays

    Hello intothewild,

    I ran the macro with no problem. It output the array values in column in the Message Box.
    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!)

  4. #4
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: strings and arrays

    Leith are you talking about AB33's solution?

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: strings and arrays

    I thought your code worked with a single dimensional, but not when you assign a range in to an array.
    If you assign(Load) a range in to an array, by default it is a 2- dim though you may only have a single column.

  6. #6
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: strings and arrays

    it works perfect AB33, and thank you for the insight!
    Last edited by intothewild; 05-15-2014 at 03:32 PM.

  7. #7
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: strings and arrays

    you could also use the transpose function to turn the array into a 1 d array as follows:

    Please Login or Register  to view this content.
    Regards,
    Tom

    If my answer resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post
    .

  8. #8
    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: strings and arrays

    Hello intotothewild,

    To answer your question, it was your code that I ran. the only thing I did was change the name of the worksheet that is activated since I don't have a worksheet by that name. Other than that change, the code ran without error.

  9. #9
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: strings and arrays

    Quote Originally Posted by Leith Ross View Post
    Hello intotothewild,

    To answer your question, it was your code that I ran. the only thing I did was change the name of the worksheet that is activated since I don't have a worksheet by that name. Other than that change, the code ran without error.
    That is odd, ive got no idea why.


    Tom, that's interesting, looks like the array only reads the first two values horizontally but them all when the vector is horizontal. Bit that I don't understand is why it didn't return the first two values in that case (I just got an error).

  10. #10
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: strings and arrays

    Not sure, I ran it with test data and no problem? When you transpose a single column range it becomes a 1D array - this doesn't work for a single row range (wel it can work but you have to transpose it twice, first transpose the range, then transpose the result).

    Leith,
    His original code had the "copy range to array line" commented out - when you ran it, it used the hand jammed array.

    Regards,
    Last edited by tom.hogan; 05-15-2014 at 04:40 PM.

+ 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] Trying to search for list of strings using Arrays,Scripting Dictionary or FileSystemObject
    By downtown1933 in forum Excel Programming / VBA / Macros
    Replies: 42
    Last Post: 10-01-2013, 04:38 AM
  2. Using Byte Arrays vs Strings
    By CyanPile in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-21-2011, 09:28 AM
  3. Comparison - Strings and Arrays
    By jbtenor1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-13-2006, 09:10 AM
  4. [SOLVED] How do I compare two arrays of numeric strings?
    By john.jacobs71 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2005, 01:00 PM
  5. [SOLVED] Help - Type mismatch when running loop with strings from arrays
    By Marie J-son in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-19-2005, 05:06 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