VBA to show result based on combobox value changed

kimberly090

Board Regular
Joined
May 22, 2014
Messages
99
Hi,

I my userform look like this:

oqSa89g21iMDERiMdn1tRA8DcLtHz9oLLdkmzd_7Gg=w660-h330-no


I have few criteria which to meet.
1. Different customer will have different process and specification
2. If the ID#(textbox1) is empty, the process and the specification will change as well.
3. Different customer will use different G-chip to carry out their progress.

As below will be my code:
Code:
Private Sub Userform_initialize()ComboBox1.List = Array("Apple", "Banana", "Watermelon")
'ComboBox2.List = Array("Ni", "NiNi", "Au", "AuAu", "Pd", "PdPd")
'ComboBox3.List = Array("Aluminium", "Copper")
End Sub


Sub CustWithPTAlu()
Select Case ComboBox1
Case "Apple"
ComboBox2.List = Array("Ni", "NiNi")
Case "Banana"
ComboBox2.List = Array("Au", "AuAu")
Case "Watermelon"
ComboBox2.List = Array("Pd", "PdPd")
End Select
End Sub


Sub CustWithPTAluArray()
Call CustWithPTAlu
    If ComboBox1.Text = "Apple" Then
        TextBox2.Value = IIf(ComboBox2.Value = "Ni", "10S", "20S")
                  Else
                  If ComboBox1.Text = "Banana" Then
        TextBox2.Value = IIf(ComboBox2.Value = "Au", "30S", "40S")
        Else
        TextBox2.Value = IIf(ComboBox2.Value = "Pd", "50S", "60S")
End If
End If
End Sub


Sub CuAl()


Select Case ComboBox1
Case "Apple"
ComboBox3.List = Array("Cu", "Al")
Case "Banana"
ComboBox3.List = Array("Cu")
Case "Watermelon"
ComboBox3.List = Array("Al")
End Select
End Sub


Sub CustXPT()
ComboBox2.List = Array("Ni", "NiAu", "NiPd", "NiPdAu")
End Sub


Sub CustXPTArray()
Call CustXPT
Select Case ComboBox2
Case "Ni"
TextBox2.Value = "70S"
Case "NiAu"
TextBox2.Value = "80S"
Case "NiPd"
TextBox2.Value = "90S"
Case "NiPdAu"
TextBox2.Value = "100S"
End Select
End Sub


Private Sub TextBox1_Change()
Call CuAl
If TextBox1.Value = "N/A" Then


Call CustXPTArray
Else


Call CustWithPTAluArray
End If
End Sub

When I try to run the code, the specification will not change. It will stay with a same number.

I have no idea, how that could happen when I have set all function one by one.

Customer: ComboBox1
ID#: TextBox1
G-chip:ComboBox3
Plating Type:ComboBox2
Lower Range:TextBox2
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I'm not great at VBA i'm still learning and i have only just scan read your code but what is "IIF" ?
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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
Back
Top