+ Reply to Thread
Results 1 to 4 of 4

Referencing Elements within an Item in a Collection

  1. #1
    Registered User
    Join Date
    02-06-2010
    Location
    Syracuse, NY
    MS-Off Ver
    Excel 2007
    Posts
    23

    Referencing Elements within an Item in a Collection

    I'm having trouble referencing elements within items I passed to a collections array. Essentially, I read each cell in a row within a 1092x6 table as an item in a collection. Now that all the cells are stored as elements within each item in a collection, I don't know how to reference each individual element.

    Here's the code:

    Please Login or Register  to view this content.
    For example, I'd like to be able to print the first value of the first item of the collection to the Immediate Window, like this:

    Please Login or Register  to view this content.
    That doesn't seem to help me reference each individual element in an item within a collection. What am I missing?

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Referencing Elements within an Item in a Collection

    You don't specify why you want to address each item into a collection. A regular array does this and seems to immediately allow you to address the items in the array by X Y coordinates:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: Referencing Elements within an Item in a Collection

    Regarding your Collection, try
    Please Login or Register  to view this content.
    Last edited by WHER; 03-21-2012 at 10:10 PM.

  4. #4
    Registered User
    Join Date
    02-06-2010
    Location
    Syracuse, NY
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: Referencing Elements within an Item in a Collection

    Thanks for the feedback, JBeaucaire. There are three reasons that I'd like to add those elements into a collection:
    • Ability to filter elements before adding them to the collection,
    • Manipulating collections in memory is better for performance,
    • Collections have keys associated with them, which means I can reference elements in a collection without knowing what position it's in

    With a large data set, it would be good to be able to reference certain elements just by referencing their keys. What do you think? Are there benefits to arrays that I'm missing?

    WHER: Thanks. I'll try that out.

+ 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