title: Excel vba: Property let procedure not defined and property get procedure did not return an object
body: <p>I have a <code>Client</code> class. Inside that class there is an array <code>losses</code>. First I create and populate with clients a <code>clientsColl</code> array. Then for each client in that array I populate its <code>losses</code> array.  </p>
  
  <p>Then I try to print into debug a first element of <code>losses</code> for each client. However, it doesnt work and <code>Property let procedure not defined and property get procedure did not return an object</code> error appears.</p>
  
  <p>And the same time if I just try to display a first element of <code>losses</code> for <em>the first</em> client, without any cycle, it works fine:</p>
  
  <pre><code>Dim clientsColl() As Client
  clientsColl = getClients(dataWorkbook)
  
  Dim clientCopy As Variant    
  
  Debug.Print "first: " &amp; clientsColl(1).getLosses(1) 'works fine
  For Each clientCopy In clientsColl
      Debug.Print "in for each: " &amp; clientCopy.getLosses(1) 'error here
  Next
  </code></pre>
  
  <p>In <code>Client</code> class:</p>
  
  <pre><code>Public Property Get getLosses()
      getLosses = losses
  End Property
  
  Private losses() As Double
  </code></pre>
  
  <p>How the <code>losses</code> array is populated:</p>
  
  <pre><code>Public Sub calculateFinancialResult()
      ReDim losses(1 To simulationCount)
      ReDim profits(1 To simulationCount)
  
      Dim i As Long
      For i = 1 To simulationCount
          If outcomes(i) = 1 Then
              losses(i) = totalLoss
              ...
          Else
              ...
          End If
      Next
   End Sub
  </code></pre>
  
  <p>Why does this happen and how to fix it?</p>
  
  <p><strong>EDIT:</strong> more of the main sub:</p>
  
  <pre><code>For Each clientCopy In clientsColl
          clientCopy.setSimulationCount = globals("SIMULATION_COUNT")
          ...
          clientCopy.calculateFinancialResult
          ...
  Next
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>At the same time a simple <code>for</code> cycle works fine:</p>
  
  <pre><code>Debug.Print "first: " &amp; clientsColl(1).getLosses(1)
  For tempCount = LBound(clientsColl) To UBound(clientsColl)
      Debug.Print "in for each: " &amp; _
                  clientsColl(tempCount).getLosses(1)
  Next
  </code></pre>