title: Add ComboBox in an Interactive UserForm in VBA
body: <p>I am using this tutorial (<a href="https://www.excel-easy.com/vba/examples/interactive-userform.html" rel="nofollow noreferrer">https://www.excel-easy.com/vba/examples/interactive-userform.html</a>) for how to create an Interactive Userform that overwrites values based on a simple condition that if ID exists, then update or edit the rows.</p>
  
  <p>However, this works very well for TextBox but I am struggling to add other controls from the Toolbox. Currently, I am trying to add ComboBox in the loops such that it can add values from the ComboBox.</p>
  
  <pre><code>Private Sub ComboBox1_Change()
  
  End Sub
  
  Private Sub CommandButton1_Click()
  EditAdd
  End Sub
  
  Private Sub CommandButton2_Click()
  ClearForm
  End Sub
  
  Private Sub CommandButton3_Click()
  Unload Me
  End Sub
  
  Private Sub TextBox1_Change()
  GetData
  End Sub
  
  Private Sub UserForm_Click()
  
  End Sub
  
  Private Sub UserForm_Initialize()
  TextBox1.SetFocus
      ComboBox1.AddItem "One"
      ComboBox1.AddItem "Two"
      ComboBox1.AddItem "Three"
      ComboBox1.AddItem "Four"
      ComboBox1.AddItem "Five"
  End Sub
  </code></pre>
  
  <p>Here is the module. I've tried to modify it by adding <code>UserForm.Controls("ComboBox" &amp; j).Value = Cells(i + 1, j).Value</code> in the <code>for</code> loops, but I only get errors.</p>
  
  <pre><code>Dim id As Integer, i As Integer, j As Integer, flag As Boolean
  
  Sub GetData()
  
  If IsNumeric(UserForm.TextBox1.Value) Then
      flag = False
      i = 0
      id = UserForm.TextBox1.Value
  
      Do While Cells(i + 1, 1).Value &lt;&gt; ""
  
          If Cells(i + 1, 1).Value = id Then
              flag = True
              For j = 2 To 6
                  UserForm.Controls("TextBox" &amp; j).Value = Cells(i + 1, j).Value
                  UserForm.Controls("ComboBox" &amp; j).Value = Cells(i + 1, j).Value
              Next j
          End If
  
  
          i = i + 1
  
      Loop
  
      If flag = False Then
          For j = 2 To 6
              UserForm.Controls("TextBox" &amp; j).Value = ""
              UserForm.Controls("ComboBox" &amp; j).Value = ""
          Next j
      End If
  
  Else
      ClearForm
  End If
  
  End Sub
  
  Sub ClearForm()
  
  For j = 1 To 6
      UserForm.Controls("TextBox" &amp; j).Value = ""
      UserForm.Controls("ComboBox" &amp; j).Value = ""
  Next j
  
  End Sub
  
  Sub EditAdd()
  
  Dim emptyRow As Long
  
  If UserForm.TextBox1.Value &lt;&gt; "" Then
      flag = False
      i = 0
      id = UserForm.TextBox1.Value
      emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
  
      Do While Cells(i + 1, 1).Value &lt;&gt; ""
  
          If Cells(i + 1, 1).Value = id Then
              flag = True
              For j = 2 To 6
                  Cells(i + 1, j).Value = UserForm.Controls("TextBox" &amp; j).Value
                  Cells(i + 1, j).Value = UserForm.Controls("ComboBox" &amp; j).Value
              Next j
          End If
  
          i = i + 1
  
      Loop
  
      If flag = False Then
          For j = 1 To 6
              Cells(emptyRow, j).Value = UserForm.Controls("TextBox" &amp; j).Value
              Cells(emptyRow, j).Value = UserForm.Controls("ComboBox" &amp; j).Value
          Next j
      End If
  
  End If
  
  End Sub
  </code></pre>
  
  <p>How can I add ComboBox into my module such that the Userform overwrites existing values if ID exists?</p>