Una familia de software de hoja de cálculo de Microsoft con herramientas para analizar, trazar y comunicar datos.
prueba esto. Tendrás que hacer algunos añadidos
Option Explicit
' los datos deben estar ordenados por nombre (ascendente) y por domicilio (descendente)
' incluir el sort te lo dejo a ti.
Sub kardex()
Dim Nombre As String
Dim NombreLista As String
Dim HE As Worksheet
Dim HS As Worksheet
Dim i As Long
Dim j As Long
Dim PrimeraLinea As Boolean
Set HE = Worksheets("PRUEBA")
Set HS = Worksheets("Salida") ' <===== crear la hoja
Nombre = InputBox("Nombre") ' el nombre debe ser EXACTO al que está en la hoja
' esto es un problema, por ejemplo existe la misma persona con CINDI y CINDY
' tambien te dejo para ti borrar los datos antes de ejecutar.
With HE
PrimeraLinea = True
For i = 2 To .Range("D1048576").End(xlUp).Cells.Row ' si version xls ultima celda D65536
NombreLista = Trim(.Cells(i, 4)) ' le quito los espacios
If Nombre > NombreLista Then
GoTo Siguiente
End If
If Nombre < NombreLista Then
MsgBox "Fin"
End
End If
If Nombre = NombreLista Then
If PrimeraLinea Then
HS.Cells(1, 2) = .Cells(i, 4) ' nombre en hs, columna 1 habrá que poner NOMBRE y formatear
HS.Cells(2, 2) = .Cells(i, 5) ' domicilio en hs, columna 1 habrá que poner DOMICILIO
HS.Cells(3, 2) = .Cells(i, 6) ' telefono
HS.Cells(5, 2) = .Cells(i, 7) ' celular
HS.Cells(4, 2) = .Cells(i, 8) ' email
HS.Cells(1, 6) = .Cells(i, 16) ' tipo de evento
HS.Cells(2, 6) = .Cells(i, 17) ' numero personas
HS.Cells(3, 6) = .Cells(i, 18) ' fecha evetno
HS.Cells(4, 6) = .Cells(i, 9) ' costo del paquete
j = 7
PrimeraLinea = False
End If
HS.Cells(j, 1) = .Cells(i, 3) ' fecha pago
HS.Cells(j, 2) = .Cells(i, 2) ' numero recibo
HS.Cells(j, 3) = .Cells(i, 11) ' anticipo
HS.Cells(j, 4) = .Cells(i, 12) ' abono
HS.Cells(j, 5) = .Cells(i, 13) ' saldo
j = j + 1
End If
Siguiente:
Next
End With
End Sub