+ Reply to Thread
Results 1 to 10 of 10

Array base

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Array base

    I have been using formulations such as
    Please Login or Register  to view this content.
    to fill arrays from worksheet ranges
    I then find that I will get error message "Subscript out of range") when an array index = 0
    However if I then use code like
    Please Login or Register  to view this content.
    The first column of the range is empty, implying that there is an empty "column" in the array, with a 0 superscript. If this is so then why do I get the error message? It does not seem to make any difference if I specify the option base value at 0 or at 1.
    This happens with all workbooks on my machine, usually I just work round it, but I have now a situation where I need a proper solution.
    I wonder if the answer lies in the Excel options. I would be grateful for some help
    John

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

    Re: Array base

    The default is option 0,but you can change it to option 1.

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

    Re: Array base

    When you upload the data in to Array = Range("name").value
    what lower and upper bound do you get? This will tell you your boundaries.

  4. #4
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Array base

    I have tried both option bases neither have an effect. AB33, I would like to find out the bounds of the array but I am not sure how to do this can you help?
    John

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    John

    You can get the upper bound with UBound and the lower with LBound.
    If posting code please use code tags, see here.

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

    Re: Array base

    Dim myarray
    myarray = Range("name").value
    Go to the code itself, go to view -local windows. Run it by pressing F8.If the range is correct and do not get any error, you will see on the windows, something like
    myarray(1 to 5, 1 to 6)
    the first 1 to 5 is the lower boundary and the second one is the upper boundary

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    AB33

    1 to 5 is the first dimension with a lower bound of 1 and upper bound of 5.

    1 to 6 is the second dimension with a lower bound of 1 and upper bound of 6.

  8. #8
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Array base

    AB3
    Thank you for view-local window. I had never got that to work before.
    It has revealed the following
    Please Login or Register  to view this content.
    Shows Array variant() in locals window
    Please Login or Register  to view this content.
    Shows Array(0 to 415, 0 to 7) in window
    Please Login or Register  to view this content.
    changes the window to Array(1 to 416, 1 to 8
    Why should this be? I am experimenting to see if option base 1 will stop this
    John

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

    Re: Array base

    by default a declared array is 0 based unless you specify otherwise-either using option base 1 or explicitly declaring a lower bound; but if you assign a multiple cell range to a variant you always get a 1 based 2 dimensional array-there is no way to alter that except by using other functions (like Transpose)
    Josie

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

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

    Re: Array base

    Norie,
    Thanks for clarifying my dimension!
    That was my intention, but did not put it the way you did.

+ 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. Converting base 10 decimal to base 5
    By dhenrynj in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-07-2020, 08:42 PM
  2. how to transform data from row-base to column-base
    By fei2010 in forum Excel General
    Replies: 3
    Last Post: 11-23-2012, 12:17 AM
  3. Leading Zeros for Base 10 to Base 36 Converter
    By norman.johnson in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-07-2011, 08:09 AM
  4. convert non data base to data base format using formula
    By murarihyd in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-22-2011, 11:42 AM
  5. Change base 6 to base 10?
    By Brian Clarke in forum Excel General
    Replies: 4
    Last Post: 05-09-2006, 09:30 AM

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