title: Looping through activeX ComboBoxes on a worksheet and assigning named range to listfill
body: <p>I have columns A and B. Each cell in column B contains an activeX <code>ComboBox</code>. What I want is for the <code>ComboBox</code> in column B to populate in reference to a named range from a different sheet based on the input in column A (directly next to the combo box)</p>
  
  <p>To do this I need to run a loop through each <code>ComboBox</code> on the worksheet with nested IF statements, but cannot figure out how to loop through the combo box objects and then assign a named range to the combo box if other conditions are true.</p>
  
  <p>For simplicity, cell A1 would be next to <code>ComboBox1</code>. Cell A2 would be next to <code>ComboBox2</code> etc.</p>
  
  <p>Basic example:</p>
  
  <pre><code>myRange1 = ActiveWorkbook.Worksheets("Ranges").Range("NamedRange1")
  myRange2 = ActiveWorkbook.Worksheets("Ranges").Range("NamedRange2")
  i = 1
  
  For Each ComboBox on ActiveWorksheet
  
  If Cell("A" &amp; i) 'condition1 here' Then
  ComboBoxi.ListFillRange = myRange1
  i = i+1
  Elseif Cell("A" &amp; i) 'condition2 here' Then
  ComboBox'i'.ListFillRange = myRange2
  i = i+1
  Else 'do nothing
  
  Next
  </code></pre>