title: Excel VBA adding values of a column into a Combo box based on another Combo box
body: <p>I want to add items in column A to combobox1 and then add item in column B to combobox2 based on combobox1 value.</p>
  
  <pre><code>   A   B
  1  a  ddd
  2  a  fgh
  3  a  jcv
  4  b  ggh
  5  b  ggg
  6  b  fff
  7  b  hhh
  </code></pre>
  
  <p>For example <br>
  If I choose "b" in combobox1 then these strings should be added to combobox2: ggh, ggg, fff and hhh<br>
  My code doesn't work. Thank you in advance.</p>
  
  <pre><code>Private Sub ComboBox1_Change()
  With Sheet3.ComboBox1
  
  For Each Cell In Range("A1:A7")
  .AddItem Cell.Value
  Next
  
  End With
  Dim index As Integer
  index = ComboBox1.value
  Call combo2
  End Sub
  
  
  Private Sub combo2()
  
  For Each Cell In Range("A1:A7")
  Select Case index
      Case Is = a
          With ComboBox2
  
              .AddItem "offset(cell.address,1,1,1,0)"
  
          End With
      Case Is = b
          With ComboBox2
              .AddItem "offset(cell.address,1,1,1,0)"
          End With
  
  End Select
  
  Next
  
  End Sub
  </code></pre>