Usar Combobox como criterio de búsqueda en excel vba

Quiero modificar un combobox en excel, tengo una planilla de inventario donde registro los movimientos de mis artículos, y me genera una hoja por articulo cuando le doy ingreso a un nuevo producto y me nombra de manera automática al darle guardar a la hoja de calculo, pero mi inconveniente esta en el desplazamiento, o sea si quiero irme a la hoja 77, el combobox me dirige, lo que quisiera es que aparezca el nombre del articulo tomando como dato de origen la hoja "BD datos" ejemplo si agregue un nuevo articulo “piedra bruta” el código siguiente es 78, yo quisiera que me aparezca también el nombre del articulo que corresponde al código 78, o no se si hay forma de agregar dos criterios de búsquedas por ejemplo al escribir %pied% que me estire todos los que tenga esas palabras claves, si me podrías ayudar te voy a agradecer

1 Respuesta

Respuesta
2

Te anexo el código para un listbox

Dim h1
'
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'Por.Dante Amor
    hoja = ListBox1.List(ListBox1.ListIndex)
    existe = False
    For Each h In Sheets
        If LCase(hoja) = LCase(h.Name) Then
            existe = True
            Exit For
        End If
    Next
    If existe Then
        Sheets(hoja).Select
        Unload Me
    Else
        MsgBox "La hoja seleccionada no existe en el libro"
    End If
End Sub
'
Private Sub TextBox1_Change()
'Por.Dante Amor
    ListBox1.Clear
    u = h1.Range("B" & Rows.Count).End(xlUp).Row
    For i = 6 To u
        cad = h1.Cells(i, "B") & h1.Cells(i, "C") & h1.Cells(i, "D")
        If LCase(cad) Like "*" & LCase(TextBox1) & "*" Then
            ListBox1.AddItem h1.Cells(i, "B")
            ListBox1.List(ListBox1.ListCount - 1, 1) = h1.Cells(i, "C")
            ListBox1.List(ListBox1.ListCount - 1, 2) = h1.Cells(i, "D")
        End If
    Next
End Sub
'
Private Sub UserForm_Activate()
'Por.Dante Amor
    Set h1 = Sheets("INVENT")
    u = h1.Range("B" & Rows.Count).End(xlUp).Row
    ListBox1.ColumnCount = 3
    ListBox1.ColumnWidths = "20"
    For i = 6 To u
        ListBox1.AddItem h1.Cells(i, "B")
        ListBox1.List(ListBox1.ListCount - 1, 1) = h1.Cells(i, "C")
        ListBox1.List(ListBox1.ListCount - 1, 2) = h1.Cells(i, "D")
    Next
End Sub
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas