I have a function that does some Dictionary operations, and it
compiles and runs perfectly. However, at the "End Function" line, I
get a runtime error 13 - type mismatch error.

Public Function CalcResourceUtilization()

    Dim t As Task
    Dim r As Resource
    Dim it As Integer
    Dim day As Date
    Dim jdict As Scripting.Dictionary
    Dim sdict As Scripting.Dictionary
    Dim rtype As String

    'm_jutilization and m_sutilization are arrays of dictionaries.
    'Each array element contains a dictionary with key = date, value =
    'int. There is one such dictionary for each iteration

    it = IterationCount
    Set m_jutilization(it) = New Scripting.Dictionary
    Set jdict = m_jutilization(it)
    Set m_sutilization(it) = New Scripting.Dictionary
    Set sdict = m_sutilization(it)

    For Each t In tasklist

        For Each r In t.AssignedResourceList

            day = r.StartDate
            rtype = r.ResourceType

            'store each day the resource worked on the task with
number of engineers
            Do While day <= r.EndDate

                If rtype = 0 Then

                    If Not jdict Is Nothing And jdict.Exists(day) Then
                        jdict.item(day) = jdict.item(day) + 1

                    Else
                        jdict.Add day, 1
                    End If
                End If

                If rtype = 1 Then

                    If Not sdict Is Nothing And sdict.Exists(day) Then
                        sdict.item(day) = sdict.item(day) + 1

                    Else
                        sdict.Add day, 1
                    End If
                End If

                day = VBA.DateAdd("d", 1, day)
            Loop

        Next r
    Next t

End Function

Any ideas why? Since all the code works perfectly until that point, I
have no idea why the error would occur there, especially since the
function doesn't return anything. I appreciate your help!

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our Facebook Group @ http://www.facebook.com/group.php?gid=287779555678
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,800 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

To unsubscribe from this group, send email to 
excel-macros+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to