title: Passing a variant as parameter to a function in VBA
body: <p>I have a function</p>
  
  <pre><code>Function convertToDict(arrayIp As Variant) As Object
  Dim dict As Object
  Set dict = CreateObject("scripting.dictionary")
  For Each element In arrayIp
  
      If dict.exists(element) Then
          dict.Item(element) = dict.Item(element) + 1
      Else
          dict.Add element, 1
      End If
  Next
  End Function
  </code></pre>
  
  <p>I tried to call this function from a sub</p>
  
  <pre><code>Dim dict As Object
  varray = Range("B4:B" &amp; finalRow - 1).Value
  dict = convertToDict(varray)
  </code></pre>
  
  <p>But it throws error:</p>
  
  <blockquote>
    <p>Run time error 450, wrong number of arguments or invalid property</p>
  </blockquote>
  
  <p>what is the mistake that I have done here?</p>
  
  <p>I am passing a variant and result is an <code>Object</code>.</p>