title: VBA Function - Argument Not Optional
body: <pre><code>Public Function RETURN_Equipment(Optional category As String) As Collection
      Dim config As classConfiguration
      Set config = New classConfiguration
  
      Dim item As classItem
      Set item = New classItem
  
      Dim myCollection As Collection
      Set myCollection = New Collection
  
      For Each config In Configurations
          For Each item In config.colItems
              If IsMissing(category) Then   
                  myCollection.add item
              ElseIf InStr(category, "mainframe") &lt;&gt; 0 And item.category = "mainframe" Then
                  myCollection.add item
                  MsgBox "Fired!"                
              ElseIf category = "accessory" And item.category = "accessory" Then
              Else
              End If
          Next
      Next
  
      RETURN_Equipment = myCollection
  End Function
  </code></pre>
  
  <p>I keep getting </p>
  
  <blockquote>
    <p>Compile error:<br>
    Argument not optional</p>
  </blockquote>
  
  <p>I get the error on the last line</p>
  
  <pre><code>RETURN_Equipment = myCollection
  </code></pre>
  
  <p>I understand the error message, its telling me I did not fill out a parameter. But I only have one parameter, and I've declared it optional. It looks like the code thinks I'm trying to call the function from the function? </p>
  
  <p>What gives?</p>