kimberly090
Board Regular
- Joined
- May 22, 2014
- Messages
- 99
Hi,
I have develop a userform inside my excel workbook.
I wish to have a alert message pop out on submit button is clicked when meet the following requirement:
1. If combobox2 value equals to Ni, the value in combobox6 need to within 50T, 30U, 20A and 100
2. If value in combobox6 is not within those value, when user hit the submit button, it will show a message box to alert user that the value for combobox6 is not within the specs, if user choose on Yes, then excel will store the data, if user select No, user will require to re-select the data.
My userform code will be look like this:
I have develop a userform inside my excel workbook.
I wish to have a alert message pop out on submit button is clicked when meet the following requirement:
1. If combobox2 value equals to Ni, the value in combobox6 need to within 50T, 30U, 20A and 100
2. If value in combobox6 is not within those value, when user hit the submit button, it will show a message box to alert user that the value for combobox6 is not within the specs, if user choose on Yes, then excel will store the data, if user select No, user will require to re-select the data.
My userform code will be look like this:
Code:
Private Sub CommandButton1_Click()
Sheets("Overall").Activate
With Me
If Len(.ComboBox1.Value) * Len(.TextBox2.Value) * Len(.TextBox3.Value) * Len(.TextBox1.Value) * Len(.ComboBox7.Value) * Len(.ComboBox3.Value) * Len(.TextBox4.Value) * Len(.TextBox5.Value) * Len(.ComboBox4.Value) * Len(.ComboBox6.Value) * Len(.ComboBox5.Value) * Len(.TextBox7.Value) * Len(.TextBox8.Value) * Len(.TextBox6.Value) * Len(.ComboBox2.Value) * Len(.TextBox9.Value) = 0 Then
MsgBox "Please Complete All Fields Before Submit"
Else
If TextBox8.Value > 3 Then
If MsgBox("TextBox8 > 3" & vbCrLf & "Continue?", vbYesNo) = vbNo Then
MsgBox "Please change the value of TextBox8"
TextBox8.SetFocus
Else
eRow = Sheet4.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(eRow, 2).Value = ComboBox1.Text
Cells(eRow, 5).Value = TextBox1.Text
Cells(eRow, 1).Value = ComboBox7.Text
Cells(eRow, 6).Value = ComboBox3.Text
Cells(eRow, 15).Value = ComboBox2.Text
Cells(eRow, 17).Value = TextBox2.Text
Cells(eRow, 18).Value = TextBox3.Text
Cells(eRow, 9).Value = ComboBox4.Text
Cells(eRow, 11).Value = ComboBox5.Text
Cells(eRow, 7).Value = TextBox4.Text
Cells(eRow, 8).Value = TextBox5.Text
Cells(eRow, 14).Value = TextBox6.Text
Cells(eRow, 16).Value = ComboBox6.Text
Cells(eRow, 12).Value = TextBox7.Text
Cells(eRow, 13).Value = TextBox8.Text
Cells(eRow, 19).Value = TextBox9.Text
End If
End If
End If
End With
End Sub
Last edited: