Solicita macro vba de búsqueda múltiple

Respuesta
1

Te anexo la macro

Sub Buscar_Dni()
'Por.Dante Amor
    Application.ScreenUpdating = False
    Set h1 = Sheets("Resultados")
    Set h2 = Sheets("Datos")
    '
    h1.Rows("6:" & Rows.Count).ClearContents
    If h1.Range("C4") = "" Then
        MsgBox "Captura el DNI"
        h1.Range("C4").Select
        Exit Sub
    End If
    '
    Set r = h2.Cells
    Set b = r.Find(h1.Range("C4"), LookAt:=xlWhole)
    If Not b Is Nothing Then
        celda = b.Address
        Do
            'detalle
            año = h2.Cells(2, b.Column)
            col = ""
            For i = 5 To h1.Cells(4, Columns.Count).End(xlToLeft).Column
                If h1.Cells(4, i) = año Then
                    col = i
                    Exit For
                End If
            Next
            '
            If col <> "" Then
                f = 6
                Do While h1.Cells(f, col + 1) <> ""
                    f = f + 1
                Loop
                h1.Cells(f, col + 1) = h2.Cells(b.Row, b.Column + 1)
                h1.Cells(f, col + 2) = h2.Cells(b.Row, b.Column + 3)
                h1.Cells(f, col + 3) = h2.Cells(b.Row, b.Column + 4)
                h1.Cells(f, col + 4) = h2.Cells(b.Row, b.Column + 5)
                h1.Cells(f, col + 5) = h2.Cells(b.Row, b.Column + 6)
            End If
            Set b = r.FindNext(b)
        Loop While Not b Is Nothing And b.Address <> celda
    End If
    Application.ScreenUpdating = True
    MsgBox "fin"
End Sub

.

'S aludos. Dante Amor

1 respuesta más de otro experto

Respuesta

Quizás a lo da dicho te aporte algo ma

https://youtu.be/MFGnxWRcTnA 

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas