Hola tengo el siguiente código para combobox dependientes pero no me funciona

los combobox son dependiente asi el 2 del 1 y el 3 del 2, dependiendo del resultado debe colocar unos datos

escribe tu código aquí

Private Sub UserForm_Initialize()
Range("A5").Select
Dim i As Long, x As Long
i = Sheets("GLOSA").Range("A" & Rows.Count).End(xlUp).Row
For x = 5 To i
If Sheets("GLOSA").Range("A" & x) <> "" Then
With ComboBoxCONCEPTO
ComboBoxCONCEPTO.AddItem Sheets("GLOSA").Range("A" & x).Value
.Column(1, .ListCount - 1) = x
End With
End If
Next x
End Sub
Private Sub ComboBoxCONCEPTO_Change()
Dim i As Long, x As Long, v As Long
With ComboBoxCONCEPTO
If ComboBoxCONCEPTO.ListIndex < 0 Then Exit Sub
i = .Column(1, ComboBoxCONCEPTO.ListIndex)
If ComboBoxCONCEPTO.ListIndex = ListCount - 1 Then
x = i + 100
Else
x = .Column(1, ComboBoxCONCEPTO.ListIndex + 1)
End If
End With
ComboBoxCODIGO.Clear
ListBoxGLOSA.Clear
For v = i To x - 2
If Sheets("GLOSA").Range("B" & v) <> "" Then
With ComboBoxCODIGO
ComboBoxCODIGO.AddItem Sheets("GLOSA").Range("B" & v).Value
.Column(1, ComboBoxCODIGO.ListCount - 1) = v
End With
End If
Next v
End Sub
Private Sub ComboBoxCODIGO_Change()
Dim i As Long, x As Long, v As Long
If ComboBoxCODIGO.ListIndex < 0 Then Exit Sub
With ComboBoxCODIGO
i = .Column(1, ComboBoxCODIGO.ListIndex)
End With
If ComboBoxCODIGO.ListIndex < ComboBoxCODIGO.ListCount - 1 Then
x = ComboBoxCODIGO.Column(1, ComboBoxCODIGO.ListIndex + 1) - 1
Else
If ComboBoxCONCEPTO.ListIndex = ComboBoxCONCEPTO.ListCount - 1 Then
x = i + 100
Else
x = ComboBoxCONCEPTO.Column(1, ComboBoxCONCEPTO.ListIndex + 1) - 1
End If
End If
ListBoxGLOSA.Clear
For v = i To x
If Sheets("GLOSA").Range("C" & v) <> "" Then
With ListBoxGLOSA
.AddItem Sheets("GLOSA").Range("C" & v).Value
.Column(1, .ListCount - 1) = v
End With
End If
Next v
End Sub
Private Sub ComboBoxGLOSA_TIPO_Change()
Dim i As Long, x As Long, v As Long
If ComboBoxGLOSA_TIPO.ListIndex < 0 Then Exit Sub
With ComboBoxGLOSA_TIPO
i = .Column(1, ComboBoxGLOSA_TIPO.ListIndex)
End With
If ComboBoxGLOSA_TIPO.ListIndex < ComboBoxGLOSA_TIPO.ListCount - 1 Then
x = ComboBoxGLOSA_TIPO.Column(1, ComboBoxGLOSA_TIPO.ListIndex + 1) - 1
Else

1 Respuesta

Respuesta
1

No está todo el código, mejor envíame tu archivo y con imágenes, colores y comentarios explícame que debe cargarse en cada combo.

Con ejemplos me dices:

Si el combo1 selecciona el dato "A"

El combo2 se carga con "Q", "W", "E"

Si el combo2 selecciona el dato "Q"

El combo3 se carga con "Z", "X", "C"

Considera los datos que vienen en tu archivo para que me digas los ejemplos.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas