Copiar el último registro de una hoja a una nueva hoja y se vallan acumulando según cambie el último registro

Hola Expertos: Mi pregunta es cómo copiar un último registro visible de datos que está en bloque (varias filas ) a una nueva hoja, sin que se borre el anterior dato es decir que valla acumulando los registros.

Ejemplo: 

HOJA 1:      ULTIMO REGISTRO-------------------------------------HOJA 2: HISTORIAL

                  Nombre     Curso          Ciclo                                 Nombre   Curso           Ciclo

                   Juan        Matemática     I                                     Juan        Matemática     I

                                   Ingles             II                                                     Ingles            II

                                                                                               Marco       Historia         III

                                                                                                               Geometría    IV 

Presionar un botón donde el último registro de la hoja ULTIMO REGISTRO pase todo el bloque de datos a la Hoja Historial, Si los datos cambian en la hoja último registro quiero que se acumulen en la hoja Historial

1 respuesta

Respuesta
1

Te anexo el código (le agregué un msgbox para que te avise que el registro fue insertado)

Private Sub CommandButton1_Click()
    Sheets("ULTIMO REGISTRO").Select
    Cells(2, 1) = TextBox23.Text
    Cells(2, 2) = TextBox2.Text
    Cells(3, 2) = TextBox4.Text
    Cells(4, 2) = TextBox6.Text
    Cells(5, 2) = TextBox11.Text
    Cells(2, 3) = TextBox7.Text
    Cells(3, 3) = TextBox8.Text
    Cells(4, 3) = TextBox9.Text
    Cells(5, 3) = TextBox12.Text
    Cells(2, 4) = TextBox14.Text
    Cells(3, 4) = TextBox15.Text
    Cells(4, 4) = TextBox16.Text
    Cells(5, 4) = TextBox17.Text
    Cells(2, 5) = TextBox18.Text
    Cells(3, 5) = TextBox19.Text
    Cells(4, 5) = TextBox20.Text
    Cells(5, 5) = TextBox21.Text
    Cells(6, 5) = TextBox13.Text
    '
    Set hu = Sheets("ULTIMO REGISTRO")
    Set hi = Sheets("HISTORIAL CURSO")
    '
    u = hi.Range("E" & Rows.Count).End(xlUp).Row
    If u > 1 Then u = u + 3
    '
    hu.Range("A1:E6").Copy hi.Range("A" & u)
    MsgBox "Último registro agregado al historial", vbInformation, "Fecha: " & Date
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas