Combobox dependiente mostrar valores únicos
Para Dante Amor
¿Hola Dan como estas?
Te quería molestar otra vez
Tengo el siguiente código que me ayudaste hace rato en esto
Lo que pasa es que tengo dos combobox ...
ComboBoxMaterial y ComboBoxLote
Al buscar en el comboboxMaterial este llena el comboboxlote
Lo que quiero es que el comboboxlote solo aparezcan valores únicos "No repetidos"
Este es el código del comboboxMaterial
Por favor
Muchas gracias
Private Sub ComboBoxMaterial_Change()
Application.ScreenUpdating = False
On Error Resume Next
Dim myrange As Range, i As Integer, Celdi As Range, NameCeldi
'ComboBoxLote.Clear
Set h = Sheets("BD")
Set b = h.Columns("A").Find(ComboBoxMaterial, lookat:=xlWhole)
If Not b Is Nothing Then
LabelUM = h.Cells(b.Row, "C")
LabelTB = h.Cells(b.Row, "B")
LabelUB = h.Cells(b.Row, "D")
End If
i = Sheets("Registros").Range("A" & Rows.Count).End(xlUp).Row
Set myrange = Sheets("Registros").Range("A2:A" & i)
ComboBoxLote.Clear
Set Celdi = myrange.Find(What:=ComboBoxMaterial.Text)
If Not Celdi Is Nothing Then
NameCeldi = Celdi.Address
Do
With ComboBoxLote
.AddItem Sheets("Registros").Range("B" & Celdi.Row)
.Column(1, .ListCount - 1) = Celdi.Row
End With
Set Celdi = myrange.FindNext(Celdi)
Loop While Not Celdi Is Nothing And Celdi.Address <> NameCeldi
End If
If ComboBoxLote.ListCount > 0 Then
With ComboBoxLote
.Visible = True
.ListIndex = 0
End With
Else
nuevo
End If
Application.ScreenUpdating = True
End Sub'
este es el codigo del comboboxLote
Private Sub ComboBoxLote_Change()
Application.ScreenUpdating = False
On Error Resume Next
Hoja4.Select
On Error Resume Next
Label28 = ""
Fila = Sheets("Registros").Range("A" & Rows.Count).End(xlUp).Row
If ComboBoxLote.ListCount > 0 Then
Fila = ComboBoxLote.List(ComboBoxLote.ListIndex, 1)
If Cells(Fila, "D") = Format(Cells(Fila, "D"), "DD-MM-YY") Then
Label28 = ("No existe fecha para este lote")
CalendarioVEN = Hoja4.Cells(Fila, "D")
LabelUM = Hoja4.Cells(Fila, "I")
LabelUB = Hoja4.Cells(Fila, "J")
LabelTB = Hoja4.Cells(Fila, "H")
LabelUB = Format(Hoja4.Cells(Fila, "J"), "DD-MM-YY")
Else
CalendarioVEN = Hoja4.Cells(Fila, "D")
Set h = Sheets("BD")
Set b = h.Columns("A").Find(ComboBoxMaterial, lookat:=xlWhole)
If Not b Is Nothing Then
LabelUM = h.Cells(b.Row, "C")
LabelTB = h.Cells(b.Row, "B")
LabelUB = h.Cells(b.Row, "D")
LabelUB = Format(LabelUB, "DD-MM-YY")
End If
'CalendarioVEN = Hoja4.Cells(Fila, "D")
'LabelUM = Hoja4.Cells(Fila, "I")
'LabelUB = Hoja4.Cells(Fila, "J")
'LabelTB = Hoja4.Cells(Fila, "H")
End If
End If
End Sub
1 Respuesta
Respuesta de Dante Amor
2