mercredi 12 juin 2019

Problem with If statement with combobox.value (Invalid use of Me keyword)

I have a problem with If statement. I have an ActiveX command button on the sheet, that should open one of six userforms, depending on combobox value.

There are 6 UserForms, and a combobox with 6 values to chose (names of UserForms)

I've tried to set the code - me.combobox.value = ".." - doesn't work Setting code with sheet name - Menu.combobox.value = ".." - same thing

Private Sub CommandButton1_Click()  

    If Me.ComboBox1.Value = "Greenhouse I" Then
     Greenhouse1.Show
    ElseIf Me.ComboBox1.Value = "Greenhouse II" Then
     Greenhouse2.Show
    ElseIf Me.ComboBox1.Value = "Greenhouse III" Then
     Greenhouse3.Show
    ElseIf Me.ComboBox1.Value = "Greenhouse IV" Then
     Greenhouse4.Show
    ElseIf Me.ComboBox1.Value = "Greenhouse V" Then
     Greenhouse5.Show
    ElseIf Me.ComboBox1.Value = "Greenhouse VI" Then
     Greenhouse6.Show

    End If
End Sub

I need that, the click on a button will open proper UserForm, depending on ComboBox value

Aucun commentaire:

Enregistrer un commentaire