Oct 23 2022 07:13 PM
Hi, I am looking for a script that will take the top 100 rows from one sheet and move it to another. Ideally, I would like it to trigger automatically every 24 hours.
Appreciate any guidance
Oct 24 2022 02:24 AM
Should the data be moved below existing data on the other sheet, or should existing data be moved down before inserting the 100 rows?
Oct 24 2022 03:27 AM
If you open the workbook once a day, you could use code in the Workbook_Open event procedure in the ThisWorkbook module:
Private Sub Workbook_Open()
Dim w1 As Worksheet
Dim w2 As Worksheet
Dim r As Long
Set w1 = Worksheets("Source")
Set w2 = Worksheets("Target")
r = w2.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
w1.Range("A2:A101").EntireRow.Copy Destination:=w2.Range("A" & r)
w1.Range("A2:A101").EntireRow.Delete
End Sub
Oct 30 2022 06:16 PM
Thank you @Hans Vogelaar that worked.
Just need to find a away for it to happen once a day without me :)