stramvaier
07-21-2011, 02:48 AM
Hi, new to vba coding and new on forum:hi:
i have a workbook in excel with 10 sheats.
names are SMART1 to 10.
in my userform i have 2 comboboxes that i want to control the selection and display of the sheets.
combobox1 has the value SMART and combobox 2 has the value 1 to 10
i then have a commandbutton that when clicked, i want it to pick the correct sheets depending on the values in the comboboxes and then display that sheet in my workbook.
i have minor skills in vba and what i have tryed so far is:
Private Sub CommandButton1_Click()
If Combobox1.Value = "SMART" & Combobox2.Value = "1" Then
ActiveWorkbook.Worksheet("SMART1").Activate
Else
If Combobox1.Value = "SMART" & Combobox2.Value = "2" Then
ActiveWorkbook.Worksheet("Smart2").Activate
Else
If Combobox1.Value = "SMART" & Combobox2.Value = "3" Then
ActiveWorkbook.Worksheet("SMART3").Activate
Else
End If
End If
End If
End Sub
this will not display the sheet i want in my excel workbook.
i am a BIG noob in VBA so please help me.
the reason for 2 comboboxes is that the value in combobox1 will change to other names in the future, but for now this is more than enough
i have a workbook in excel with 10 sheats.
names are SMART1 to 10.
in my userform i have 2 comboboxes that i want to control the selection and display of the sheets.
combobox1 has the value SMART and combobox 2 has the value 1 to 10
i then have a commandbutton that when clicked, i want it to pick the correct sheets depending on the values in the comboboxes and then display that sheet in my workbook.
i have minor skills in vba and what i have tryed so far is:
Private Sub CommandButton1_Click()
If Combobox1.Value = "SMART" & Combobox2.Value = "1" Then
ActiveWorkbook.Worksheet("SMART1").Activate
Else
If Combobox1.Value = "SMART" & Combobox2.Value = "2" Then
ActiveWorkbook.Worksheet("Smart2").Activate
Else
If Combobox1.Value = "SMART" & Combobox2.Value = "3" Then
ActiveWorkbook.Worksheet("SMART3").Activate
Else
End If
End If
End If
End Sub
this will not display the sheet i want in my excel workbook.
i am a BIG noob in VBA so please help me.
the reason for 2 comboboxes is that the value in combobox1 will change to other names in the future, but for now this is more than enough