VBA Excel - Formulario que muestre datos al digitar en un TextBox
Sucede que estoy haciendo una macro para digitando un Apellido en TextBox1, salga los datos en el ListBox en 4 columnas: Doc. Identidad, Apellidos y Nombres, Código, Fin de Contrato. Esos datos lo sacan de una hoja llamada MatrizMod cuyo 1er Apellido aparece en la celda B5 de aceurdo a la siguiente extructura.
A5 - Doc. Identidad / B5 - Apellidos y Nombres / C5 - Código / Entre J5 y AE5 - Fecha de Fin de Contrato (Siempre coloco la nueva fecha de manera horizontal y deseo que me reconozca el último dato colocado de ese rango).
He usado este código de manera provisional pero me lanza error en la parte M=InStr...
Private Sub TextBox1_Change()
Application.ScreenUpdating = False
Sheets("MatrizMod").Select
Range("B5").Select
ListBox1.Clear
While ActiveCell.Value <> ""
M = InStr(1, UCase(ActiveCell.Value), UCase(TexBox1.Text))
If M > 0 Then
ListBox1.ColumnCount = 4
ListBox1.AddItem
ActiveCell.Offset(0, -1).Select
ListBox1.List(ListBox1.ListCount - 1, 0) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
ListBox1.List(ListBox1.ListCount - 1, 1) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
ListBox1.List(ListBox1.ListCount - 1, 2) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
ListBox1.List(ListBox1.ListCount - 1, 3) = ActiveCell.Value
ActiveCell.Offset(0, -4).Select
End If
ActiveCell.Offset(1, 0).Select
Wend
Sheets("MatrizMod").Select
Range("A1").Select
Application.ScreenUpdating = True
End SubQuisiera saber mi error en este código.
1 respuesta
Respuesta de Abraham Valencia
1
