+ Reply to Thread
Results 1 to 11 of 11

Multiple and variant item of dictionary

  1. #1
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,513

    Multiple and variant item of dictionary

    I Want to save item multiple item in one key
    1. as value
    2. as range (union range)
    3.as number
    IS Posible to save multiple variant typename of item from each key
    Please Login or Register  to view this content.
    Last edited by daboho; 09-26-2018 at 11:38 AM.
    "Presh Star Who has help you *For Add Reputation!! And mark case as Solve"

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Multiple and variant item of dictionary

    d(e)(1) is a range of cells and the MsgBox is expecting text.

    This might work to display the cells address
    MsgBox d(e)(1).Address

    Or the value of the first cell
    MsgBox d(e)(1)(1).Value
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,513

    Re: Multiple and variant item of dictionary

    still not run AlphaFrog
    Q = d(k)
    Q(0) = Q(0) & "," & sn(i, 1)
    Q(1) = Union(Q(1), Cells(i, 1)) 'this need to set but i can not write coding 'OBJECT REQUAIRED
    Q(2) = Q(2) + 1
    d(k) = Q
    Last edited by daboho; 09-26-2018 at 12:34 PM.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Multiple and variant item of dictionary

    still not understand

  5. #5
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,513

    Re: Multiple and variant item of dictionary

    Sub bb()
    Dim d As Object, i&, ii&, j&, sn, k, Q
    sn = [a1:b6].Value
    Set d = CreateObject("scripting.dictionary")
    For i = 1 To UBound(sn)
    k = sn(i, 1) & sn(i, 2)
    If Not d.exists(k) Then

    d.Add k, Array(sn(i, 1), Cells(i, 1), 1)
    Else
    Q = d(k)
    Q(0) = Q(0) & "," & sn(i, 1)
    Q(1) = Union(Q(1), Cells(i, 1))
    Q(2) = Q(2) + 1
    d(k) = Q
    End If
    Next i
    For Each ky In d
    If d(ky)(2) = 1 Then
    d.Remove ky
    End If
    Next ky

    For Each e In d.keys
    MsgBox d(e)(0) ' this OK
    MsgBox d(e)(1) ' how to d(e)(1) not error i has change to MsgBox d(e)(1)(1).Value but still error
    Next e
    End Sub

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

    Re: Multiple and variant item of dictionary

    What is it you actually want to store in the dictionary?

    What's in the range A1:B6?
    If posting code please use code tags, see here.

  7. #7
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,513

    Re: Multiple and variant item of dictionary

    norri i hope you understand what i want from my coding to save any variant item FOR each key
    1.Save range.address 'for interior colorindex
    2.save range.row 'for copy data if meet criteria from third item
    3.number 'only duplikat to executed IF NUMBER > 1
    Please Login or Register  to view this content.
    NORI.png
    Last edited by daboho; 09-26-2018 at 03:08 PM.

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

    Re: Multiple and variant item of dictionary

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED, scroll down and click Manage Attachments.

  9. #9
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,513
    Quote Originally Posted by Norie View Post
    Any chance you could upload a sample workbook?

    Click on GO ADVANCED, scroll down and click Manage Attachments.
    I am sorri nori
    My oponion single dictionary can not
    Save multiple typename of item
    My code has sucsess using (range.address)
    Please Login or Register  to view this content.
    Last edited by daboho; 09-27-2018 at 06:49 AM.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997

    Re: Multiple and variant item of dictionary

    You should be using Set with objects:

    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  11. #11
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,513
    Quote Originally Posted by rorya View Post
    You should be using Set with objects:

    Please Login or Register  to view this content.
    Ok thankyou

+ 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] Finding corresponding key in dictionary based on item value
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2018, 07:38 AM
  2. [SOLVED] Get total of an item in dictionary
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-24-2017, 07:02 PM
  3. [SOLVED] Can a dictionary key hold more than one item?
    By dwx in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-17-2015, 07:00 AM
  4. [SOLVED] Can a dictionary key hold more than one item?
    By dwx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2015, 04:37 AM
  5. [SOLVED] If dictionary key exists add new item to existing item array
    By strud in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-25-2014, 01:54 PM
  6. Remove All Instances Of Key Item Pairs From Dictionary
    By goss in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-31-2013, 12:37 AM
  7. 2 Dimentional Array as Dictionary Item
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-05-2011, 11:13 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