1
Sub Copy()

Workbooks("Data.xlsm").Sheets("28May2020").Select

Workbooks("Data.xlsm").Sheets("28May2020").Activate

Dim lastrow As Integer

lastrow = ThisWorkbook.Sheets("COPYHERE").Cells(Rows.Count, 2).End(xlUp).Row

Sheets("COPYHERE").Range("A" & lastrow + 1).Value = Date
Sheets("COPYHERE").Range("B" & lastrow + 1).Value = Time

Range("L43:X93").Copy Worksheets("COPYHERE").Range("A" & lastrow + 2)

Sheets("COPYHERE").Select

Timer

End Sub

Sub Timer()

Application.OnTime Now() + TimeValue("00:00:30"), "Copy"

End Sub
braX
  • 11,506
  • 5
  • 20
  • 33

2 Answers2

0

Before Sheets("COPYHERE").Select, place a line ThisWorkbook.Activate. That activates the workbook running the code.

Also take another look at
Sheets("COPYHERE").Range("A" & lastrow + 1).Value = Date
Sheets("COPYHERE").Range("B" & lastrow + 1).Value = Time
Range("L43:X93").Copy Worksheets("COPYHERE").Range("A" & lastrow + 2)
Sheets, Worksheets and Range refer to ActiveWorkbook/ActiveSheet. Unless you're sure that's what you want, I recommend you change Sheets to ThisWorkbook.Sheets, Worksheet to ThisWorkbook.Worksheet and Range to ThisWorkbook.Sheets(<sheet name>).Range(<address>).

0
Sub Copy()
Application.ScreenUpdating = True

Dim lastrow As Integer
Dim wsName As String
Dim cpName As String

wsName = "28May2020"
cpName = "COPYHERE"
Sheets(wsName).Activate

lastrow = Sheets(cpName).Cells(Rows.Count, 2).End(xlUp).Row

With Sheets(cpName)
    .Range("A" & lastrow + 1).Value = Date
    .Range("B" & lastrow + 1).Value = Time
End With

Range("L43:X93").Copy Worksheets(cpName).Range("A" & lastrow + 2)

Sheets(cpName).Activate

Application.ScreenUpdating = False

End Sub



Anabas
  • 346
  • 1
  • 7