Thanks to Nimrod, this is the code Im using.
Public Sub MainCopyProcedure()
Workbooks.Open Filename:="C:\Documents and Settings\David Culshaw\My Documents\master.xls"
On Error Resume Next
' the variables are : (SourceBk, SourceSht, TargBk, TargSht)
Call CopyRow3("Paul.xls", "dailyfigures", "Master.xls", "Paul")
On Error Resume Next
Call CopyRow3("Mark.xls", "dailyfigures", "Master.xls", "Mark")
On Error Resume Next
Call CopyRow3("John.xls", "dailyfigures", "Master.xls", "John")
On Error Resume Next
End Sub
Private Sub CopyRow3(SourceBk, SourceSht, TargBk, TargSht)
With Workbooks(TargBk).Sheets(TargSht)
NxRw = .Cells(65536, 1).End(xlUp).Row + 1
Workbooks(SourceBk).Sheets(SourceSht).Range("3:3").Copy _
Destination:=.Range(NxRw & ":" & NxRw)
End With
End Sub
the extra line I have added is to open the master sheet. Its the 3rd line down. What is the best way to go trying to open this workbook, without getting errors if it is already open. ie, if it is already open when the macro is run then ignore that request and carry one with the rest of the code.
Thanks.
Public Sub MainCopyProcedure()
Workbooks.Open Filename:="C:\Documents and Settings\David Culshaw\My Documents\master.xls"
On Error Resume Next
' the variables are : (SourceBk, SourceSht, TargBk, TargSht)
Call CopyRow3("Paul.xls", "dailyfigures", "Master.xls", "Paul")
On Error Resume Next
Call CopyRow3("Mark.xls", "dailyfigures", "Master.xls", "Mark")
On Error Resume Next
Call CopyRow3("John.xls", "dailyfigures", "Master.xls", "John")
On Error Resume Next
End Sub
Private Sub CopyRow3(SourceBk, SourceSht, TargBk, TargSht)
With Workbooks(TargBk).Sheets(TargSht)
NxRw = .Cells(65536, 1).End(xlUp).Row + 1
Workbooks(SourceBk).Sheets(SourceSht).Range("3:3").Copy _
Destination:=.Range(NxRw & ":" & NxRw)
End With
End Sub
the extra line I have added is to open the master sheet. Its the 3rd line down. What is the best way to go trying to open this workbook, without getting errors if it is already open. ie, if it is already open when the macro is run then ignore that request and carry one with the rest of the code.
Thanks.