Macro en excel para buscar ultima fila selecciónala, córtala y pegarla en otra hoja

Como puedo hacer una macro que me busque la ultima fila de "A" en la hoja 1 la seleccione hasta "D" corte esa selección y la pegue en la hoja 2 en el ultimo registro pegado en esa hoja y así repetirlo hasta la primera fila con datos.

1 Respuesta

Respuesta
3

Intente con esta macro, actualiza el dato a buscar del que se cortara y pegara en la hoja2

Sub copiar()
Set h1 = Sheets("Hoja1")
Sheets("Hoja1").Select
uf = h1.Cells(Rows.Count, 1).End(xlUp).Row
    For i = 2 To uf
        nombre = h1.Cells(i, 1).Value
        If nombre = "jose" Then
            ini = h1.Cells(i, 1).Address
            fin = h1.Cells(i, 4).Address
            Range(ini & ":" & fin).Cut
            Set h2 = Sheets("Hoja2")
            uf = h2.Cells(Rows.Count, 1).End(xlUp).Row + 1
                For x = 2 To uf
                    nombre = h2.Cells(x, 1).Value
                    If nombre = "" Then
                    Sheets("Hoja2").Select
                        h2.Cells(x, 1).Select
                        ActiveSheet.Paste
                        Application.CutCopyMode = False
                        Exit Sub
                    End If
                Next x
        End If
    Next i
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas