+ Reply to Thread
Results 1 to 5 of 5

Jagged dictionary or collection filled via variables

  1. #1
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Jagged dictionary or collection filled via variables

    Hi all,

    I hope I can describe my wish / problem.

    I have a dictionary, let's say "KIDS" that I want to fill with multi-dimensional values.
    So, I'd want to say:

    KIDS.ADD(JOE) - but JOE is another dictionary.
    Then I want to be able to say:
    JOE.ADD(AGE) = 12
    JOE.ADD(PET) = "GOLDFISH" etc

    Problem is that "Joe" would come through a variable.
    In essence the structure would be

    KIDS - JOE - AGE - value
    KIDS - JOE - PET - value
    KIDS - SUE - AGE - value
    KIDS - SUE - FAVCOLOR - value

    etc.
    The first ("kids") I can name fixed.
    The third ("age", "pet", "favcolor") I can also name/refer to fixed.
    But values and kids names are variables.

    Can I do this and if so, how?
    Thanks,

    Jasper

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Jagged dictionary or collection filled via variables

    There are several ways to do it...

    One way to do it is to create multi-level dictionary.

    See sample code below. This assumed data in range "A2:D5" and headers in Row 1. See attached as well.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Jagged dictionary or collection filled via variables

    Please Login or Register  to view this content.

  4. #4
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Jagged dictionary or collection filled via variables

    Thanks CK76, Jindon - that's an excellent solution.
    For some reason I thought you cannot have a dictionary of dictionaries - but I was wrong

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Jagged dictionary or collection filled via variables

    You are welcome, thanks for the rep.
    I learned about this about a year ago when I was solving problem of assigning records into separate bin, based on unique id and limited bin size.

+ 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. Dictionary vs Collection Speed
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2016, 05:48 AM
  2. [SOLVED] Dictionary or Scripting.Dictionary. Binding Referencing Dim-ing. Sub routines and Function
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-12-2016, 08:28 AM
  3. Dictionary/Collection/Other for XML/API Table Upload
    By JTWood in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-10-2013, 01:02 PM
  4. 2010 VBA - Ordered by Collection or Scripting.Dictionary
    By Herve_Rob in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-06-2013, 12:14 PM
  5. Sum of variables in collection
    By gosa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-24-2012, 06:02 AM
  6. Collection vs Dictionary
    By MattShoreson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-12-2007, 10:43 AM
  7. Limitation of collection and dictionary datatype
    By iamrajy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2006, 12:58 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