Función If en combobox
Publicado por Eduardo Herrera (1 intervención) el 20/09/2023 10:22:18
Quiero poder simplificar este código, de manera que funcione como un BuscarV, no se si se pueda
Private Sub UserForm_Initialize()
ComboBox1.List = Worksheets("Listas").Range("A2:A8").Value
End Sub
Private Sub ComboBox1_Change()
If ComboBox1.Text = "Lista 1" Then
Label9.Caption = Worksheets("Listas").Range("b1").Value
Else
If ComboBox1.Text = "Lista 2" Or ComboBox1.Text = "Lista 3" Then
Label9.Caption = Worksheets("Listas").Range("b2").Value
Else
If ComboBox1.Text = "Lista 4" Then
Label9.Caption = Worksheets("Listas").Range("b3").Value
Else
If ComboBox1.Text = "Lista 5" Or ComboBox1.Text = "Lista 6" Or ComboBox1.Text = "Lista 7" Then
Label9.Caption = Worksheets("Listas").Range("b6").Value
End If
End If
End If
End If
End If
End If
End Sub
Listas Operdadores
Lista 1 operador 1
Lista 2 operador 2
Lista 3 operador 2
Lista 4 operador 3
Lista 5 operador 4
Lista 6 operador 4
Lista 7 operador 4
Private Sub UserForm_Initialize()
ComboBox1.List = Worksheets("Listas").Range("A2:A8").Value
End Sub
Private Sub ComboBox1_Change()
If ComboBox1.Text = "Lista 1" Then
Label9.Caption = Worksheets("Listas").Range("b1").Value
Else
If ComboBox1.Text = "Lista 2" Or ComboBox1.Text = "Lista 3" Then
Label9.Caption = Worksheets("Listas").Range("b2").Value
Else
If ComboBox1.Text = "Lista 4" Then
Label9.Caption = Worksheets("Listas").Range("b3").Value
Else
If ComboBox1.Text = "Lista 5" Or ComboBox1.Text = "Lista 6" Or ComboBox1.Text = "Lista 7" Then
Label9.Caption = Worksheets("Listas").Range("b6").Value
End If
End If
End If
End If
End If
End If
End Sub
Listas Operdadores
Lista 1 operador 1
Lista 2 operador 2
Lista 3 operador 2
Lista 4 operador 3
Lista 5 operador 4
Lista 6 operador 4
Lista 7 operador 4
Valora esta pregunta


0