title: Cannot iterate Hashtable in VBA (Excel)
body: <p>I am using Hashtable (mscorlib.dll referenced). I fill it with data, I can get any item (as long as I convert the request type to exactly same type what's stored in hashtable), .ContainsValue/Key - all that works. But I cannot iterate through it via For Each loop.
  I've tried all methods I could find on the internet (For Each element..., where element is DictionaryEntry, via GetEnumerator), but none works - I can roll through the table via enumerator, but I can't reach the key nor value of where the iterator is positioned. What am I doing wrong?
  I've solved it temporarily by setting keys to numbers and iterating over those numbers, but it won't work, because finally there will be the same number twice...</p>
  
  <p>P.S.: I can't use Dictionary instead of Hashtable, because I need both ContainsKey and ContainsValue and also being able to retrieve items by keys or by values.</p>
  
  <p>EDIT: my current code (what I am looking for is to replace "For i" loop, so I don't need keys to be numbers I already know)</p>
  
  <pre><code>For i = 1 To UBound(rands)
          chopped_yes = Split(ThisWorkbook.Worksheets(1).Range("Z" &amp; rands(i)))
          chopped_no = Split(ThisWorkbook.Worksheets(1).Range("AA" &amp; rands(i)))
          chopped_any = Split(ThisWorkbook.Worksheets(1).Range("AB" &amp; rands(i)))
          For Each part In chopped_yes
              If rules_yes.ContainsValue(cscs.item(CLng(rands(i)))) Then
                  validcsc = 0
                  GoTo WriteIt
              End If
          Next part
          For Each part In chopped_no
              If rules_no.ContainsValue(cscs.item(CLng(rands(i)))) Then
                  validcsc = 0
                  GoTo WriteIt
              End If
          Next part
          For Each part In chopped_any
          pepa = cscs.item(CLng(rands(i)))
          chopped_pepa = Split(pepa, "=")
              If rules_any.ContainsValue(CStr(chopped_pepa(0))) Then
                  validcsc = 0
                  GoTo WriteIt
              End If
          Next part
      Next i
  </code></pre>
  
  <p>What the code does:</p>
  
  <hr>
  
  <p>cscs hashtable contains keyword/option_value pair, some keywords conflict with others, hashtables rules_any/yes/no contain keywords which conflict, if the checked one is keyword=YES/NO/SOMETHING and set validcsc to 0 (aka invalid combination of keywords).</p>
  
  <hr>
  
  <p>rands is array of unique numbers - trouble is if there is more than one conflict keyword, then I don't have any number to set as key which I will know later and use it to iterate</p>