+ Reply to Thread
Results 1 to 9 of 9

Array length

  1. #1
    Forum Contributor
    Join Date
    07-04-2014
    Location
    Netherlands
    MS-Off Ver
    all
    Posts
    121

    Lightbulb Array length

    The myRows() array got some value like: 1, 2, 3, 4, 5
    In my First executed code all works and gives me the right array length.
    'Sorry can't show you the data..


    ...At this time i would like to see what is left of it by Calling the updateRecords.

    Why does it execute but don't gives me the array length there?
    Are there better ways to see the Array length?


    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,991

    Re: Array length

    The argument to CountA must be a Range object. Sometimes documentation says that it can be an array, but that is an Excel sheet array, not a VBA array variable.

    In your case, the array starts at element 0, so the number of elements is the upper bound + 1.

    Please Login or Register  to view this content.
    If you have bounds that are not the default, you need this:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    07-04-2014
    Location
    Netherlands
    MS-Off Ver
    all
    Posts
    121

    Re: Array length

    I start with this this code, wich runs good:

    Please Login or Register  to view this content.
    Lets say MsgBox (max_user_items) got 8
    From there I walk trough the rows.
    This runs good. When adding a row the Array is still 8.
    Thats where the Call updateRecords is needed.

    How to set this up that it outputted 7 and after adding a new row 6, etc.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,470

    Re: Array length

    Not entirely sure why you need to use an array.

    Please Login or Register  to view this content.

    This could be made into a function and, if required, called from the worksheet.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please Login or Register  to view this content.

    This relates specifically to column A although it could be amended to work with any range.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Contributor
    Join Date
    07-04-2014
    Location
    Netherlands
    MS-Off Ver
    all
    Posts
    121

    Re: Array length

    thnx for the inputs. What code is for output the last array item?

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,470

    Re: Array length

    Please Login or Register  to view this content.

    Regards, TMS

  7. #7
    Forum Contributor
    Join Date
    07-04-2014
    Location
    Netherlands
    MS-Off Ver
    all
    Posts
    121

    Re: Array length

    Sorry, I'm strugling with my own code first.

    At this moment its hard to find the latest array.
    I think I started with two different wrong numbers. Zero and One.
    I can't find where this bug is. Everything is working fine, except the latest handling.

    Please Login or Register  to view this content.
    Above do the trick for everything but.... this:

    Ive found out that this code below will allways be one number short.
    It never match to the exact value.


    Please Login or Register  to view this content.
    Changing to this won't help neither.
    whoIsOn +1 = max -1
    whoIsOn = max
    whoIsOn = max -1

    If I do this all they futher actions are mixed up! ^&@*##@^$

    What goes wrong!>&#$(@

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,470

    Re: Array length

    OK, I'm struggling too. I have no idea what your data looks like, what the end to end code looks like, or what you are trying to achieve.

    When you are given code, you know all this ... but we don't. So it's hard to work out what it needs to do.


    Regards, TMS

  9. #9
    Forum Contributor
    Join Date
    07-04-2014
    Location
    Netherlands
    MS-Off Ver
    all
    Posts
    121

    Re: Array length

    OUTPUT:

    Item whoIsOn: 0 - MAX ITEMS 6
    Item whoIsOn: 1 - MAX ITEMS 6
    Item whoIsOn: 2 - MAX ITEMS 6
    Item whoIsOn: 3 - MAX ITEMS 6
    Item whoIsOn: 4 - MAX ITEMS 6 = Latest record ???????????
    Item whoIsOn: 5 - MAX ITEMS 6 = Latest record ???????????

    Ok Item whoIsOn: 4 is exctually whoIsOn 5 becuz it starts @ zero. And than max -1 = one less if there are 6 items in this case.
    So 5 is indeed the latest record
    Whats the why to solve this? To get a proper value "Latest record" in only Item whoIsOn: 5 - MAX ITEMS 6

+ 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. Limiting the array length in LOOKUP
    By Peterb1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-03-2014, 04:03 PM
  2. [SOLVED] VBA to change Array Length!
    By sianjialin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-16-2013, 05:27 AM
  3. Max Length in Array
    By yawnzzzz in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-21-2010, 05:42 AM
  4. Length of Array question
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-24-2008, 12:24 AM
  5. [SOLVED] length of an array
    By april27 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2006, 10:10 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