title: How to loop through options in a drop down list?
body: <p>I am trying to loop through the options or items of a drop down menu, but I don't know the number of items as it will be changeable every time.</p>
  
  <p>Here's the html part of the sList3</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;select name="ctl00$ContentPlaceHolder1$Dschool" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$Dschool\',\'\')', 0)" id="ContentPlaceHolder1_Dschool" style="font-size:12pt;font-weight:bold;width:500px;"&gt;
   &lt;option selected="selected" value="0"&gt; Select From Menu &lt;/option&gt;
   &lt;option value="311223"&gt;first option&lt;/option&gt;
   &lt;option value="311625"&gt;some option&lt;/option&gt;
  &lt;/select&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here's my code that I have started </p>
  
  <pre><code>For i = 1 To 4
      Set sList1 = .FindElementById("ContentPlaceHolder1_Dedara").AsSelect
      sList1.SelectByIndex i
      .Wait 2000
      Set sList2 = .FindElementById("ContentPlaceHolder1_Drel").AsSelect
      sList2.SelectByIndex 1
      .Wait 2000
      Set sList3 = .FindElementById("ContentPlaceHolder1_Dschool").AsSelect
  
      'How can I loop through the options (unknown in length)
  Next i
  </code></pre>
  
  <p>I would like to loop each option and debug.print the value of the option.</p>
  
  <h2>SOLUTION</h2>
  
  <p>With the help of JeffC this is the final solution</p>
  
  <pre><code>            For j = 1 To sList3.Options.Count
              Debug.Print sList3.Options(j).Text
          Next j
  </code></pre>