Ajustar macro para realizar buscar con más coincidencia excel vba
Ajusté la macro a mi necesidad y funciona, solo un pequeño retoque faltaría.
Tengo en la columna código"B" y apellidos y nombres en "C".
Realizo la búsqueda por ejemplo ortiz y en la base de existe
Ortiz saldaña, xxx
Ortiz sanchez, xx
¿Y la macro solo me arroja un resultado por que será?
Private Sub CommandButton1_Click()
''Por DAM
Set h1 = Sheets("PRINCIPAL")
Set h2 = Sheets("Temp")
'
If Me.txtFiltro1.Value = "" Then Exit Sub
'
h2.Cells.Clear
ListBox1.RowSource = ""
h1.Rows(2).Copy h2.Rows(1)
'
n = 2
'
For i = 3 To h1.Range("A3").CurrentRegion.Rows.Count
cad = h1.Cells(i, "C") & UCase(h1.Cells(i, "C")) & h1.Cells(i, "B") ' bucar por nombre y DNI
If cad Like "*" & UCase(txtFiltro1) & "*" Then
h1.Rows(i).Copy h2.Rows(n)
n = n + 1
End If
Next i
u = h2.Range("A" & Rows.Count).End(xlUp).Row
If u = 1 Then
MsgBox "No existen registros con ese filtro", vbExclamation, "FILTRO"
Exit Sub
End If
ListBox1.RowSource = h2.Name & "!B3:N" & u
End Sub
2 respuestas
Respuesta de Dante Amor
2
Respuesta de Elsa Matilde
2