Elaborar una macro en Excel

Para Dante Amor, lo que deseo es hacer una macro que me jale información de mi hoja BASE a la hoja Lista, ya sea mediante un combo o una lista flotante y que me permita escribir parte del nombre y me filtre las coincidencias y a la vez me permita seleccionar el nombre del trabajador y poder anexarlo mediante un botón Anexar o haciendo clic en la fila que deseo anexar pero que me jale los cuatro campos de la derecha. Quedare agradecido por su ayuda.

1 respuesta

Respuesta
1

]H   o l a:

Envíame tu archivo y me explicas con detalle y con ejemplos reales lo que tienes y lo que esperas como resultado

Mi correo [email protected]

En el asunto del correo escribe tu nombre de usuario “Edward Guzman

S a l u d o s . D a n t e   A m o r

Te envié archivo adjunto en tu correo. Gracias

Te anexo las macros

Private Sub CommandButton1_Click()
'Por.Dante Amor
    If ListBox1.ListCount = 0 Or ListBox1.ListIndex = -1 Then
        MsgBox "Selecciona un registro"
        Exit Sub
    End If
    Set h2 = Sheets("Lista")
    u = h2.Range("A" & Rows.Count).End(xlUp).Row + 1
    H2.Cells(u, "A") = ListBox1. List(ListBox1. ListIndex, 0)
    H2.Cells(u, "B") = ListBox1. List(ListBox1. ListIndex, 1)
    H2.Cells(u, "C") = ListBox1. List(ListBox1. ListIndex, 2)
    H2.Cells(u, "D") = ListBox1. List(ListBox1. ListIndex, 3)
    H2.Cells(u, "E") = ListBox1. List(ListBox1. ListIndex, 4)
    MsgBox "Registro agregado"
    TextBox1 = ""
    TextBox1.SetFocus
End Sub
'
Private Sub TextBox1_Change()
'Por.Dante Amor
    Set h1 = Sheets("BASE")
    ListBox1.Clear
    If TextBox1 = "" Then Exit Sub
    For i = 2 To h1.Range("A" & Rows.Count).End(xlUp).Row
        If LCase(h1.Cells(i, "A")) Like "*" & TextBox1 & "*" Then
            ListBox1. AddItem h1.Cells(i, "A")
            ListBox1. List(ListBox1.ListCount - 1, 1) = h1.Cells(i, "B")
            ListBox1. List(ListBox1.ListCount - 1, 2) = h1.Cells(i, "C")
            ListBox1. List(ListBox1.ListCount - 1, 3) = h1.Cells(i, "D")
            ListBox1. List(ListBox1.ListCount - 1, 4) = h1.Cells(i, "E")
        End If
    Next
End Sub

sal u dos

¡Gracias! Dante Amor, es justo la macro que quería, gracias por ahorrarme un poco el trabajo y sobre todo tiempo, gracias muchas gracias desde Perú - Piura - Chulucanas. Un abrazo.

Hola Dante Amor, no me aparece el siguiente mensaje de la macro o en que momento aparece, el resto todo bien. Gracias.

If ListBox1.ListCount = 0 Or ListBox1.ListIndex = -1 Then
        MsgBox "Selecciona un registro"
        Exit Sub

Antes de realizar la búsqueda, es decir, antes de escribir algo en el textbox presiona el botón

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas