Reputation: 496
I have the following piece of code and would like to modify it a bit. Basically with every case is
i want to check a secondary criteria. For example Case is = "Lottery"
i want to add on AND range("SalesChannel").value = "SMB"
. i would then like to replicate that for every case is using a different value (not SMB). can this be done?
Private Sub CommandButton1_Click()
With LoginPassword.TextBox1.Value
Select Case Me.TextBox1.Value
Case Is = "Lottery"
LoginPassword.Hide
SMB_Login
CalculateFinancials
Case Is = "Charity"
LoginPassword.Hide
DCS_Login
CalculateFinancials
Case Is = "Curfew"
LoginPassword.Hide
Campaign_Login
CalculateFinancials
Case Is = "Europe"
LoginPassword.Hide
Eureka_Login
CalculateFinancials
Case Is = "Promo"
LoginPassword.Hide
Promo_Login
CalculateFinancials
Case Is = "Sundew"
LoginPassword.Hide
Loyalty_Login
CalculateFinancials
Case Is = "Casino"
LoginPassword.Hide
MobilePricing.Hide
Range("Network").ClearContents
Case Is = "RedDevil"
HardwareUpdateYesNo
Case Is = "Provision"
LoginPassword.Hide
MobilePricing.Hide
ProvisioningView
Case Else
MsgBox "Password Incorrect!", vbCritical + vbOKOnly, "Login Failed!"
TextBox1.Text = ""
TextBox1.SetFocus
End Select
End With
End Sub
Upvotes: 1
Views: 6050
Reputation: 43595
This is a sample Select Case with multiple criteria:
Option Explicit
Public Sub TestMe()
Select Case True
Case 1 = 1 And True
Debug.Print 1
Case True And 2 = 5
Debug.Print 2
Case True And 5 = 5 And 6 = 7
Debug.Print 3
End Select
End Sub
In your case you should simply write your conditions instead of 1=1
or True
. Like this: Case Me.TextBox1.Value = "Lottery" and range("SalesChannel").value = "SMB"
But leave Select Case True
on the top.
Upvotes: 1