jeudi 27 août 2020

Excel Userform Text field validation

I'm making a userform that has multiple text boxes, for Example Combobox1 = ReasonForRequestField and Combobox2 = Requestnotcreatedfield, if Combobox1 = Reason 1 or Reason 2 then the validation will require the user to select an outcome from Combobox2, but if Combobox1 = Reason 3 or 4 then Combobox2 is not required.

i have tried the validation below but it wont allow me submit with Reason 1 in Combobox1

If Me.ReasonForRequestField.Value = "Reason1" Then

MsgBox " Please select a reason from Drop Down below " , vbExclamation, " Request not created field "

Me.Requestnotcreatedfield.SetFocus

Exit Sub

End If

i found this example on here but couldnt figure out how to adapt the variables to my form

If combobox1.Text = "1 - 2 yr" And (CDbl(textbox2.Value) < 1 Or CDbl(textbox2.Value) > 2) Then MsgBox ("Enter correct value") ElseIf combobox1.Text = And Then... End If

i hope i explained what i'm after ok, Any help would be Greatly appreciated :)

Thanks.

Aucun commentaire:

Enregistrer un commentaire