I want to return to the userform if the msgbox occurres (then a text / listbox is empty) so the textbox can be filled before populating the data to the worksheet.
Can anyone help me please?
Private Sub CommandButton1_Click()
If ListBox5.Value = "" Or ListBox1.Value = "" Or CheckBox1.Value = False And CheckBox2.Value = False Or ListBox3.Value = "" Or ListBox6.Value = "" Or ListBox7.Value = "" Or TextBox3.Value = "" Or ListBox2.Value = "" Or TextBox1.Value = "" Or TextBox2.Value = "" Or TextBox4.Value = "" Or DTPicker1.Value = "" Then MsgBox "Please fill in all content"
Worksheets("Data").Range("A3").Value = ListBox5.Value
Worksheets("Data").Range("B3").Value = ListBox1.Value
Worksheets("Data").Range("C3").Value = TextBox6.Value
Worksheets("Data").Range("E3").Value = ListBox3.Value
Worksheets("Data").Range("F3").Value = ListBox6.Value
Worksheets("Data").Range("G3").Value = ListBox7.Value
If CheckBox1.Value = True Then
Worksheets("Data").Range("H3").Value = "YES"
End If
If CheckBox2.Value = True Then
Worksheets("Data").Range("H3").Value = "NO"
End If
Worksheets("Data").Range("I3").Value = TextBox3.Value
Worksheets("Data").Range("J3").Value = ListBox2.Value
Worksheets("Data").Range("L3").Value = TextBox1.Value
Worksheets("Data").Range("M3").Value = TextBox2.Value
Worksheets("Data").Range("N3").Value = TextBox4.Value
Worksheets("Data").Range("O3").Value = DTPicker1.Value
Worksheets("Data").Range("P3").Value = TextBox7.Value
Unload Me
Worksheets("Overview").Select
Range("A2").Select
End Sub
Bookmarks