Hello,
I am using Userform to let users select options to show Charts, but there seems to be a logical error. Is it correct for me to use the And function here to apply multiple conditions?
Could anyone help me to take a look at my code please?
Dim Selection
Dim a, b, c, d, e As Integer
a = Me.opt1.Value
b = Me.opt2.Value
c = Me.opt3.Value
d = Me.optBarChart.Value
e = Me.optPieChart.Value
Select Case Selection
Case a And d
Call Data1_BarChart
'Shows Bar Chat for Data 1
Case a And e
Call Data1_PieChart
'Shows Pie Chat for Data 1
Case b And d
Call Data2_BarChart
'Shows Bar Chat for Data 2
Case b And e
Call Data2_PieChart
'Shows Pie Chat for Data 2
Case a And b And d
Call Data1_and_Data2_BarChart
'Shows Bar Chat for Data 1
End Select
End Sub
Why is my last case showing the Chart for the first case instead? I have tried using the IF ELSEIF statement, and I received the same result...
I wonder if I am allowed to use the AND function in Userform like this?
I am using Userform to let users select options to show Charts, but there seems to be a logical error. Is it correct for me to use the And function here to apply multiple conditions?
Could anyone help me to take a look at my code please?
Dim Selection
Dim a, b, c, d, e As Integer
a = Me.opt1.Value
b = Me.opt2.Value
c = Me.opt3.Value
d = Me.optBarChart.Value
e = Me.optPieChart.Value
Select Case Selection
Case a And d
Call Data1_BarChart
'Shows Bar Chat for Data 1
Case a And e
Call Data1_PieChart
'Shows Pie Chat for Data 1
Case b And d
Call Data2_BarChart
'Shows Bar Chat for Data 2
Case b And e
Call Data2_PieChart
'Shows Pie Chat for Data 2
Case a And b And d
Call Data1_and_Data2_BarChart
'Shows Bar Chat for Data 1
End Select
End Sub
Why is my last case showing the Chart for the first case instead? I have tried using the IF ELSEIF statement, and I received the same result...
I wonder if I am allowed to use the AND function in Userform like this?