Agregar datos a otra hoja cada vez que ingrese registros
Buenos días, hace poco hice una pregunta en todo expertos sobre pasar datos de una hoja llamada "datos" a otra hoja y la respuesta me fue de gran ayuda, modificando el código pude resolver la mayoría de inconvenientes excepto la siguiente:
-como manejo una cantidad diaria de 100 filas ingresadas, quisiera poder pasar los registros de la hoja "datos" hacia la otra hoja pero solo los que se vallan ingresando en ese día y así sucesivamente, sin tener que filtrar toda l información previamente llenada.
Dejo el código (gracias experto Dam) que esta modificado para que solo pasen ciertas columnas hacia la otra hoja y no limpie la hoja al pasarlas. Muchas gracias por su tiempo y respuesta.
Sub numeros3()
'Pone códigos únicos en otra hoja
'Por.Dam (modificado)
Dim encontrado As Boolean
Set h1 = Sheets("datos")
Set h2 = Sheets("Hoja1")
h2.Cells.Clear
h1.Select
For i = 2 To h1.Range("A" & Rows.Count).End(xlUp).Row
encontrado = False
For j = 1 To h2.Range("A" & Rows.Count).End(xlUp).Row
If h1.Cells(i, "A") = h2.Cells(j, "A") _
And h1.Cells(i, "B") = h2.Cells(j, "B") _
And h1.Cells(i, "C") = h2.Cells(j, "C") _
And h1.Cells(i, "D") = h2.Cells(j, "D") _
And h1.Cells(i, "F") = h2.Cells(j, "E") Then
[size= 0.8em; line-height: 1.1em]encontrado = True[/size]
End If
Next
If encontrado = False Then
h2.Range("A" & h2.Range("A" & Rows.Count).End(xlUp).Row + 1) = h1.Cells(i, "A")
h2.Range("B" & h2.Range("B" & Rows.Count).End(xlUp).Row + 1) = h1.Cells(i, "B")
h2.Range("C" & h2.Range("C" & Rows.Count).End(xlUp).Row + 1) = h1.Cells(i, "C")
h2.Range("D" & h2.Range("D" & Rows.Count).End(xlUp).Row + 1) = h1.Cells(i, "D")
[size= 0.8em; line-height: 1.1em]h2.Range("E" & h2.Range("E" & Rows.Count).End(xlUp).Row + 1) = h1.Cells(i, "F")[/size]
End If
Next
h2.Select
Range("A1").Value = "Codigo"
Range("B1").Value = "Cliente"
Range("C1").Value = "Producto"
Range("D1").Value = "Material"
Range("E1").Value = "Fecha"
Range("A1:E1").Select
Selection.Font.Bold = True
Selection.HorizontalAlignment = xlCenter
Selection.End(xlDown).Select
MsgBox "Proceso terminado", vbInformation, "Códigos"
End Sub
1 respuesta
Respuesta de Dante Amor
1
Buenas podrían publicar como quedó la macro final? Así todos aprendemos o tengo que publicar la pregunta nuevamente? - Mario Alvarado