I am using the following to copy and paste data. However if I use a second spreadsheet at the same time I get an error (I use Japanese windows so not sure of the english translation but the error code is '9'). I'm guessing I need to not only specify the sheet but also the spreadsheet itself to where the data is being copied. Any assistance here would be muchly appreciated
[VBA]Public RunWhen As Double
Public Const cRunIntervalSeconds = 60 'seconds
Public Const cRunWhat = "TheSub" ' the name of the procedure to run
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=False
End Sub
Sub TheSub()
Application.ScreenUpdating = False
''''''''''''''''''''''''
With Worksheets("Data")
LastRow = .Range("C" & Rows.Count).End(xlUp).Row + 1
Worksheets("Sheet1").Range("A42:F42").Copy
.Range("C" & LastRow).PasteSpecial Paste:=xlPasteValues
End With
''''''''''''''''''''''''
StartTimer ' Reschedule the procedure
End Sub
[/VBA]