Results 1 to 4 of 4

Get stored value from existing item in dictionary

Threaded View

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Get stored value from existing item in dictionary

    Hello everyone

    I am trying the following code
    Sub Test()
        Dim a, dic As Object, s As String, i As Long, j As Long
       
        a = ThisWorkbook.Worksheets("Sheet1").Range("A1").CurrentRegion.Value
        a = Application.Index(a, Evaluate("ROW(1:" & UBound(a, 1) & ")"), [{3,7,13,14,15,16,17,18,19,20,21}])
       
        Set dic = CreateObject("Scripting.Dictionary")
        dic.CompareMode = 1
    
        For i = LBound(a) To UBound(a)
            s = a(i, 1) & vbTab & a(i, 2)
            If Not dic.Exists(s) Then
                dic.Add s, s
               
                For j = LBound(a, 2) To UBound(a, 2)
                    If j = 1 Or j = 3 Or j = 6 Or j = 9 Then
                        If i > 1 Then a(i, j) = CLng(Application.WorksheetFunction.WorkDay(CDate(a(i, 1)), IIf(j = 1, 0, Val(j / 3))))
                    End If
                Next j
            Else
                'Need Here Some Help
                Stop
            End If
        Next i
       
    End Sub
    What I need to add in this code is to detect if the item existing in the dictionary or not
    If new then some calculations will be done ..on columns M to U
    And if it is already exists, there is no need to do the calculations again .. just bring the results from the existing

    run the above code and have a look at a(7), you will find it empty as it is already existed before
    What I need for a(7) for example [This is a duplicate one] >> So I need to take the results in a(7,3) to a(7,11) from existing item
    The exisitng item or the first instance of 20/04/2009 and "N" was in a(6)
    So I would like to fill a(7,3) to a(7,11) with the same values in a(6,3) to a(6,11)

    Posted at this link too
    Attached Files Attached Files
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Sort key and item in dictionary using arraylist
    By daboho in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-24-2018, 07:48 AM
  2. Multiple and variant item of dictionary
    By daboho in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-27-2018, 11:51 AM
  3. [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
  4. [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
  5. [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
  6. [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
  7. [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

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