Add Condition to User Form Code

erock24

Well-known Member
Joined
Oct 26, 2006
Messages
1,161
I am using the following code on my text box in my user form.

Rich (BB code):
Private Sub txtSYS_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim ws As Worksheet
Set ws = Worksheets("Request Form")
With Me.txtSYS
Trim(cboCat.Value) = "2-Capital Replacement" And Trim(cboLoc.Value) <> "405 - HEADQUARTERS" And Trim(txtSYS.Value) = "00" Then

How can I edit the if statement to say if cbo.cat ="2-Capital....." and cboLoc. does not equal "405....." or "406..." or "409..." and txt.sys = "00" Then

Thank you.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

John_w

MrExcel MVP
Joined
Oct 15, 2007
Messages
7,788
Like this maybe.
Code:
Private Sub txtSYS_Exit(ByVal Cancel As MSForms.ReturnBoolean)

Dim ws As Worksheet
Dim sCat As String, sLoc As String
Set ws = Worksheets("Sheet1")

sCat = Trim(cboCat.Value)
sLoc = Trim(cboLoc.Value)

If sCat = "2-Capital Replacement" And _
    sLoc <> "405 - HEADQUARTERS" And sLoc <> "406 - HEADQUARTERS" And sLoc <> "409 - HEADQUARTERS" And _
    Trim(txtSYS.Value) = "00" Then
    MsgBox "All conditions satisfied"
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,191,092
Messages
5,984,612
Members
439,896
Latest member
SquareCare

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top