Private Sub CommandButton1_Click()
Dim cNum As Integer
Dim x As Integer
Dim nextrow As Range
Dim sht As String
Dim f As Range
If Me.TextBox1.Value = "" Then
MsgBox "Name Required"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox2.Value = "" Then
MsgBox "Gender Required"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox3.Value = "" Then
MsgBox "Please Choose 1 or more Sections"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox4.Value = "" Then
MsgBox "Please Enter A Primary Email"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox7.Value = "" Then
MsgBox "URL Required"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox8.Value = "" Then
MsgBox "HandleRequired"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox9.Value = "" Then
MsgBox "Followers Number Required"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox10.Value = "" Then
MsgBox "Rate Number Required"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox11.Value = "" Then
MsgBox "Date Required"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox12.Value = "" Then
MsgBox "Platform Required"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox13.Value = "" Then
MsgBox "Country Required"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox14.Value = "" Then
MsgBox "Followers Group Required"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox15.Value = "" Then
MsgBox "Rate Group Required"
Me.TextBox1.SetFocus
Exit Sub
End If
'set the variable for the sheet
sht = ComboBox1.Value
'check for values
If Me.ComboBox1.Value = "" Then
MsgBox "Please Select A sheet"
Exit Sub
End If
'Prevent duplicates in column H
Set f = Sheets(sht).Range("H:H").Find(TextBox8.Value, , xlValues, xlWhole)
If Not f Is Nothing Then
MsgBox "Handle already exists: " & TextBox8.Value
Exit Sub
End If
'change the number for the number of controls on the userform
cNum = 15
'add the data to the selected worksheet
Set nextrow = Sheets(sht).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
For x = 1 To cNum
nextrow = Me.Controls("TextBox" & x).Value
Set nextrow = nextrow.Offset(0, 1)
Next
'clear the values in the userform
For x = 1 To cNum
Me.Controls("TextBox" & x).Value = ""
Next
'communicate the results
MsgBox "The values have been sent to the " & sht & " sheet"
Dim arrItems()
Dim cnt As Long
Dim pro As Long
For pro = 0 To TextBox3.ListCount - 1
If TextBox3.Selected(pro) Then
ReDim Preserve arrItems(cnt)
arrItems(cnt) = TextBox3.List(pro)
cnt = cnt + 1
End If
Next pro
If cnt > 0 Then
Sheets(sht).Range("C" & Rows.Count).End(xlUp).Value = Join(arrItems, "|")
End If
Dim HowManyRows As Long
HowManyRows = 12
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
lstdisplay.ColumnCount = 15
lstdisplay.Clear
lstdisplay.List = Cells(Lastrow - HowManyRows + 1, 1).Resize(HowManyRows, 15).Value