title: Collection Maximum Size
body: <p>Here's my code:</p>
  
  <pre><code>Sub isdofsodjisf48023jroi23f984444444jiodfiosj12348023jroi23f98()
  
  
  Dim colFiles As New Collection
      RecursiveDir colFiles, "C:\Documents and Settings\Alex Gordon\Desktop\testing\files\", "*.xls", True
  
      Dim vFile As Variant
      For Each vFile In colFiles
          Call writeincells(vFile)
      Next vFile
  
  End Sub
  
  
  
  Public Function RecursiveDir(colFiles As Collection, _
                               strFolder As String, _
                               strFileSpec As String, _
                               bIncludeSubfolders As Boolean)
  
      Dim strTemp As String
      Dim colFolders As New Collection
      Dim vFolderName As Variant
  
      'Add files in strFolder matching strFileSpec to colFiles
      strFolder = TrailingSlash(strFolder)
      strTemp = Dir(strFolder &amp; strFileSpec)
      Do While strTemp &lt;&gt; vbNullString
          colFiles.Add strFolder &amp; strTemp
          strTemp = Dir
      Loop
  
      If bIncludeSubfolders Then
          'Fill colFolders with list of subdirectories of strFolder
          strTemp = Dir(strFolder, vbDirectory)
          Do While strTemp &lt;&gt; vbNullString
              If (strTemp &lt;&gt; ".") And (strTemp &lt;&gt; "..") Then
                  If (GetAttr(strFolder &amp; strTemp) And vbDirectory) &lt;&gt; 0 Then
                      colFolders.Add strTemp
                  End If
              End If
              strTemp = Dir
          Loop
  
          'Call RecursiveDir for each subfolder in colFolders
          For Each vFolderName In colFolders
              Call RecursiveDir(colFiles, strFolder &amp; vFolderName, strFileSpec, True)
          Next vFolderName
      End If
  
  End Function
  
  
  Public Function TrailingSlash(strFolder As String) As String
      If Len(strFolder) &gt; 0 Then
          If Right(strFolder, 1) = "\" Then
              TrailingSlash = strFolder
          Else
              TrailingSlash = strFolder &amp; "\"
          End If
      End If
  End Function
  </code></pre>
  
  <p>I am filling up a Collection with a list of filenames in a directory structure.</p>
  
  <p>I have 2000 files, but the Collection only return 256. Does anyone know if there is a maximum number that it won't go past?</p>
  
  <p>If so, can you please suggest a better way to code this macro so that it captures all 2000 files?</p>