Hi All,
What I currently have is a userform (userform3) that people on my team complete, and once they have filled out all relevant fields, they click a command button which populates the first blank row on a sheet called "Data". If the sheet is incomplete it returns an error message with words to that affect. If the sheet is completed correctly it opens a messagebox stating the claim has been updated.
I now wish to add a further condition that if one of the comboboxes (combobox8) on userform 3 returns the result "ABC" then after updating the "Data" sheet , it will open up userform 4, bypassing the messagebox mentioned above. and will close userform 3. If the combobox doesn't return "ABC" it will carry on as before.
Here is the code I currently have:
I think I need to add in something like:
But I'm not entirely sure where to add it!!
Any help would be really appreciated
What I currently have is a userform (userform3) that people on my team complete, and once they have filled out all relevant fields, they click a command button which populates the first blank row on a sheet called "Data". If the sheet is incomplete it returns an error message with words to that affect. If the sheet is completed correctly it opens a messagebox stating the claim has been updated.
I now wish to add a further condition that if one of the comboboxes (combobox8) on userform 3 returns the result "ABC" then after updating the "Data" sheet , it will open up userform 4, bypassing the messagebox mentioned above. and will close userform 3. If the combobox doesn't return "ABC" it will carry on as before.
Here is the code I currently have:
Code:
Private Sub CommandButton1_Click()
Dim lastrow As Object
Dim flag As Boolean
Worksheets("Data").Unprotect Password:="Password"
flag = False
If TextBox1.Text = "" Then
flag = True
End If
If ComboBox7.Text = "" Then
flag = True
End If
If ComboBox8.Text = "" Then
flag = True
End If
If TextBox7.Text = "" Then
flag = True
End If
If ComboBox3.Text = "" Then
flag = True
End If
If TextBox25.Text = "" Then
flag = True
End If
If TextBox28.Text = "" Then
flag = True
End If
If TextBox27.Text = "" Then
flag = True
End If
If TextBox53.Text = "" Then
flag = True
End If
If TextBox26.Text = "" Then
flag = True
End If
If TextBox2.Text = "" Then
flag = True
End If
If TextBox3.Text = "" Then
flag = True
End If
If TextBox8.Text = "" Then
flag = True
End If
If ComboBox9.Text = "" Then
flag = True
End If
If TextBox10.Text = "" Then
flag = True
End If
If TextBox12.Text = "" Then
flag = True
End If
If TextBox14.Text = "" Then
flag = True
End If
If ComboBox4.Text = "" Then
flag = True
End If
If TextBox11.Text = "" Then
flag = True
End If
If TextBox52.Text = "" Then
flag = True
End If
If TextBox42.Text = "" Then
flag = True
End If
If TextBox29.Text = "" Then
flag = True
End If
If flag = False Then
Set lastrow = Sheet5.Range("a65536").End(xlUp)
lastrow.Offset(1, 0).Value = CDate(TextBox1.Value)
lastrow.Offset(1, 1).Value = ComboBox7.Text
lastrow.Offset(1, 4).Value = ComboBox8.Text
lastrow.Offset(1, 5).Value = TextBox7.Text
lastrow.Offset(1, 6).Value = ComboBox3.Text
lastrow.Offset(1, 7).Value = TextBox25.Text
lastrow.Offset(1, 9).Value = TextBox28.Text
lastrow.Offset(1, 10).Value = TextBox27.Text
lastrow.Offset(1, 11).Value = TextBox53.Text
lastrow.Offset(1, 8).Value = TextBox26.Text
lastrow.Offset(1, 12).Value = TextBox30.Text
lastrow.Offset(1, 14).Value = TextBox2.Text
lastrow.Offset(1, 15).Value = TextBox3.Text
lastrow.Offset(1, 16).Value = TextBox29.Text
lastrow.Offset(1, 17).Value = CDate(TextBox8.Value)
lastrow.Offset(1, 18).Value = ComboBox9.Text
lastrow.Offset(1, 19).Value = TextBox10.Text
lastrow.Offset(1, 20).Value = Label15.Caption
lastrow.Offset(1, 21).Value = TextBox11.Text
lastrow.Offset(1, 22).Value = Label20.Caption
lastrow.Offset(1, 23).Value = TextBox12.Text
lastrow.Offset(1, 24).Value = TextBox13.Text
lastrow.Offset(1, 25).Value = TextBox14.Text
lastrow.Offset(1, 26).Value = ComboBox4.Text
lastrow.Offset(1, 39).Value = TextBox52.Text
lastrow.Offset(1, 28).Value = TextBox42.Text
Worksheets("Data").Protect Password:="Password"
MsgBox "Insurance Claim ADDED"
response = MsgBox("Do you want to enter another insurance claim?", vbYesNo)
If response = vbYes Then
ComboBox7.SetFocus
TextBox1.Text = Format(Now(), "DD-MM-YYYY")
ComboBox7.Text = ""
ComboBox8.Text = ""
TextBox7.Text = ""
ComboBox3.Text = ""
TextBox25.Text = ""
TextBox28.Text = ""
TextBox27.Text = ""
TextBox53.Text = ""
TextBox26.Text = ""
TextBox30.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox29.Text = ""
TextBox8.Text = ""
ComboBox9.Text = ""
TextBox10.Text = ""
Label15.Caption = ""
TextBox11.Text = ""
Label20.Caption = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""
ComboBox4.Text = ""
TextBox52.Text = ""
TextBox42.Text = ""
Else
Unload Me
End If
Else
MsgBox "Claim Form Incomplete"
End If
End Sub
I think I need to add in something like:
Code:
If ComboBox8.Text = "ABC" then
Unload Me
UserForm4.Show
But I'm not entirely sure where to add it!!
Any help would be really appreciated