title: Loop a collection made by VBA class
body: <p>I'm trying to loop a collection. I can expand and see &quot;the elements&quot; inside VBE but get the error:</p>
  <blockquote>
  <p>&quot;Object doesn't support this property or method&quot;.</p>
  </blockquote>
  <p>In a standard module I have</p>
  <pre><code>Public collItems As Collection
  </code></pre>
  <p>The collection is populated inside a userform module on initialization</p>
  <pre><code>collItems.add cItems
  </code></pre>
  <p><code>cItems</code> is an object made from <code>New clsItems</code>, which is the class module.</p>
  <p>The class module consists of many userform controls like this:</p>
  <pre><code>Private WithEvents frm As msforms.Frame
  Private WithEvents lbl As msforms.Label
  Private WithEvents cmd As msforms.CommandButton
  Private WithEvents txt1 As msforms.TextBox
  Private WithEvents txt2 As msforms.TextBox 
  +++
  </code></pre>
  <p>Not sure if <code>Private</code> is the way to go on this.</p>
  <p>When the userform finishes loading, a dynamic number of frames with all these textboxes inside each frame appears. It looks like a spreadsheet made from data inside MS Project. The command buttons job is to change a lot of the textbox's attributes/properties.</p>
  <p>I want to loop the collItems collection but then I get an error.</p>
  <p>I don't have any <code>get</code>  or <code>let</code>  in my class, just a single <code>set</code> property.
  It might look stupid to add 10 unique textboxes inside the class, but that's how I made it work so far. All the form objects are given names that refer to row and column during creation and helps me identify them.</p>
  <p>The failing code looks like this:</p>
  <pre class="lang-vb prettyprint-override"><code>Sub changeBox(ByRef name As String)
  For Each item in collItems.item(CLng(Replace(name, &quot;cmd&quot;, &quot;&quot;)))
      'blabla
  Next item
  End Sub
  </code></pre>
  <p>This test works and shows all the elements I want to loop:</p>
  <pre><code>Set test = collItems.item(3) 'Meaning row 3 in userform
  </code></pre>
  <p>How do I loop my specific textboxes and change their attributes?</p>