+ Reply to Thread
Results 1 to 6 of 6

String Length within an Array: ERROR [Excel 2010/14] (VBA Only)

  1. #1
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    String Length within an Array: ERROR [Excel 2010/14] (VBA Only)

    Are you allowed to limit the length of a string within an array?

    I want to limit this to 2 characters:
    Please Login or Register  to view this content.
    I tried the following but get an "expected end of statement error"
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: String Length within an Array: ERROR [Excel 2010/14] (VBA Only)

    lloydgodin,

    I would limit it when assigning a string to a position within the array using the Left method:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: String Length within an Array: ERROR [Excel 2010/14] (VBA Only)

    OK.

    I just remembered that there is a different sub for the actual user input where I can limit the string length. I would not need to limit it when it is being read into the array at that point as it's already done.

    What is this ERASE feature? I have not seen it before.

  4. #4
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: String Length within an Array: ERROR [Excel 2010/14] (VBA Only)

    OK.

    I just remembered that there is a different sub for the actual user input where I can limit the string length. I would not need to limit it when it is being read into the array at that point as it's already done.

    What is this ERASE feature? I have not seen it before.

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: String Length within an Array: ERROR [Excel 2010/14] (VBA Only)

    Erase is used to free up memory that has been dedicated to array storage:
    http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: String Length within an Array: ERROR [Excel 2010/14] (VBA Only)

    fyi you were pretty close
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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