.
Here is an example of a basic database that you can work from :
Option Explicit
Sub mdSubmit_Click()
Dim wsBranch As Worksheet
Dim cNum As Integer
Dim X As Integer
Dim newRow As Long
'set the variable for the sheet
Set wsBranch = Worksheets(ComboBox1.Value)
'check for values
If Me.ComboBox1.Value = "" Then
MsgBox "Select a sheet from the combobox"
Exit Sub
End If
With wsBranch
newRow = Application.WorksheetFunction.CountA(wsBranch.Range("A:A")) + 1
wsBranch.Cells(newRow, 1).Value = txtName.Value
wsBranch.Cells(newRow, 2).Value = txtFatherName.Value
wsBranch.Cells(newRow, 3).Value = txtMotherName.Value
wsBranch.Cells(newRow, 4).Value = ComboBox1.Value
Unload Me
'communicate the results
MsgBox "The values have been sent to the " & ComboBox1.Value & " sheet"
End With
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Sheet1"
.AddItem "Sheet2"
.AddItem "Sheet3"
End With
End Sub
Sub cmdSubmit_Click()
Dim wsBranch As Worksheet
Dim NextRow As Long
If ComboBox1.ListIndex = -1 Then
MsgBox "Please select a branch."
Exit Sub
Else
Set wsBranch = Worksheets(ComboBox1.Value)
End If
With wsBranch
NextRow = .Range("A" & Rows.Count).End(xlUp).Offset(1).Row
.Range("A" & NextRow).Resize(, 3).Value = Array(txtName.Value, txtFatherName.Value, txtMotherName.Value)
End With
End Sub