title: How to update data of an excel sheet in a userform with vba
body: <p>U would like to know how i can retrieve data from an excel sheet and update it in a userform. </p>
  
  <p>on the picture you can see what the userform looks like.
  What i would like to do is make another userform that can search for a specific reference in the sheet and update some cells of that specific row.</p>
  
  <p><a href="https://i.stack.imgur.com/uoOYx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uoOYx.png" alt="Userform"></a>
  This is the code I have now to insert data into the sheet.  </p>
  
  <pre><code>Private Sub cmdClear_Click()
  ' Clear the form
   For Each ctl In Me.Controls
   If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
   ctl.Value = ""
   ElseIf TypeName(ctl) = "CheckBox" Then
   ctl.Value = False
   End If
   Next ctl
  End Sub
  
  Private Sub cmdSend_Click()
      Dim RowCount As Long
      Dim ctl As Control
  ' Check user input
  
      If Me.combTechnieker.Value = "" Then
          MsgBox "Dag vreemdeling! Welke van de 4 Mongolen ben je?", vbExclamation, "RMA invoer"
          Me.combTechnieker.SetFocus
          Exit Sub
      End If
  
      If Me.txtPcwRef.Value = "" Then
          MsgBox "Vul onze referentie in!", vbExclamation, "RMA invoer"
          Me.txtPcwRef.SetFocus
          Exit Sub
      End If
  
      If Me.txtKlant.Value = "" Then
          MsgBox "Vul de naam van de klant in!", vbExclamation, "RMA invoer"
          Me.txtKlant.SetFocus
          Exit Sub
      End If
  
      If Me.txtMerk.Value = "" Then
          MsgBox "Vul het merk in!", vbExclamation, "RMA invoer"
          Me.txtMerk.SetFocus
          Exit Sub
      End If
  
      If Me.txtMerkRef.Value = "" Then
          MsgBox "Vul de referentie van de fabrikant in!", vbExclamation, "RMA invoer"
          Me.txtMerkRef.SetFocus
          Exit Sub
      End If
  
      If Me.txtProduct.Value = "" Then
          MsgBox "Vul het product in!", vbExclamation, "RMA invoer"
          Me.txtProduct.SetFocus
          Exit Sub
      End If
  
      If Me.txtSerienummer.Value = "" Then
          MsgBox "Vul het serienummer in!", vbExclamation, "RMA invoer"
          Me.txtSerienummer.SetFocus
          Exit Sub
      End If
  
      If Me.txtProbleem.Value = "" Then
          MsgBox "Vul de probleem omschrijving in!", vbExclamation, "RMA invoer"
          Me.txtProbleem.SetFocus
          Exit Sub
      End If
  
      If Me.txtOnderdelen.Value = "" Then
          MsgBox "Bent u zeker dat er geen onderdelen achterblijven. Indien ja. Vul N/A in", vbExclamation, "RMA invoer"
          Me.txtOnderdelen.SetFocus
          Exit Sub
      End If
  
  ' Write data to worksheet
      RowCount = Worksheets("RMA 2016").Range("A1").CurrentRegion.Rows.Count
  
      With Worksheets("RMA 2016").Range("A1")
          .Offset(RowCount, 0).Value = Format(Now, "dd/mm/yyyy hh:nn:ss")
          .Offset(RowCount, 1).Value = "Open"
          .Offset(RowCount, 3).Value = Me.txtPcwRef.Value
          .Offset(RowCount, 4).Value = Me.txtKlant.Value
          .Offset(RowCount, 5).Value = Me.txtMerk.Value
          .Offset(RowCount, 6).Value = Me.txtMerkRef.Value
          .Offset(RowCount, 7).Value = Me.txtProduct.Value
          .Offset(RowCount, 8).Value = Me.txtSerienummer.Value
          .Offset(RowCount, 9).Value = Me.txtOnderdelen.Value
          .Offset(RowCount, 10).Value = Me.txtProbleem.Value
          .Offset(RowCount, 13).Value = Me.combTechnieker.Value
  
      If Me.chkGarantie.Value = True Then
       .Offset(RowCount, 2).Value = "Ja"
       Else
      .Offset(RowCount, 2).Value = "Nee"
      End If
      End With
      ' Clear the form
       For Each ctl In Me.Controls
       If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
       ctl.Value = ""
      ElseIf TypeName(ctl) = "CheckBox" Then
      ctl.Value = False
      End If
      Next ctl
  End Sub
  
  Private Sub UserForm_Click()
  
  End Sub
  </code></pre>