+ Reply to Thread
Results 1 to 12 of 12

Add 2 items into dictionary

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Add 2 items into dictionary

    Hi Guys,

    i want to add 3 items into dictionary:

    Table name as key , table address and array of headers from table as items

    Somehing like

    dic.add "t_test", "[Sheet1$A1:C4]", ArrayNames
    where ArrayNames = "Lp, First Name, Last Name"
    What is the best solution here?
    Create class for this ?

    I am not good with classes but maybe this is time to implement them...

    Best,
    Jacek

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

    Re: Add 2 items into dictionary

    Like this?
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Add 2 items into dictionary

    Hi jindon,

    thank you but when i will be splitting ArrayNames it should be done separately from "[Sheet1$A1:C4]".

    Best,
    Jacek

  4. #4
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Add 2 items into dictionary

    So

    cell(1,1).value = key
    cel(2,1).value = [Sheet1$A1:C4]
    cell(3,1).value ="Lp"
    cell(4,1).value ="First Name"
    cell(5,1).value ="Last Name"

    edit:
    for last three i can use split function.

    Best,
    Jacek
    Last edited by jaryszek; 06-15-2018 at 09:28 AM.

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

    Re: Add 2 items into dictionary

    When you retrieve the item
    Please Login or Register  to view this content.

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

    Re: Add 2 items into dictionary

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Add 2 items into dictionary

    jindon,

    thank you very much.

    This is working.
    The second metohs is great.

    If i have arraynames like here:

    Screenshot_7.png

    I can modyfy first code to:

    Please Login or Register  to view this content.
    But second code is not working.

    How can i resize arraynames using second dimension in my case?

    How to get
    UBound(dic("t_test")(1))
    from 2cd dimension?

    Best,
    Jacek

  8. #8
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Add 2 items into dictionary

    ok this is working !

    UBound(dic("t_test")(1), 2)
    so classes are not useful here?

    Best,
    Jacek

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

    Re: Add 2 items into dictionary

    That's because you said
    where ArrayNames = "Lp, First Name, Last Name"
    So I thought it was a 0 based 1D array.
    It should be
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Add 2 items into dictionary

    thank you.

    joindon you are using classes sometimes ?
    Or classes are rarely useful?

    Best,
    Jacek

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

    Re: Add 2 items into dictionary

    Only sometime like put common Event together for Controls on a user form.

  12. #12
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Add 2 items into dictionary

    jindon,

    thank you

    can you show some example? I am very courious and love your code

    Best,
    Jacek

+ 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. [SOLVED] Dictionary Items to Listview
    By sunjam in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-10-2018, 12:22 AM
  2. Add items to a key dynamically in dictionary?
    By max138 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2017, 11:57 AM
  3. [SOLVED] Write Dictionary items to Worksheet
    By WmBarth in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2017, 03:18 AM
  4. Add items to dictionary - VBA Help Needed
    By mitko007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-26-2015, 07:26 AM
  5. [SOLVED] Looping through dictionary items where items are an array
    By strud in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2014, 06:56 AM
  6. Nested dictionary items, how do you access them?
    By treyr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2010, 12:23 PM
  7. looping through items in a dictionary
    By Abe in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-08-2006, 05:45 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