In my example I used it as export for a time sheet. The example is only a (very) small piece of the VBA script, gathering records, copying them to an export sheet, and saving it with a unique name, containing user-id and week-number. In this1st example a new file is created:
Sub Export()
' Select Data to Export
Windows("SourceFile.xls").Activate
Sheets("DataSource").Select
' Create copy of exported data as new file
Sheets("DataSource").Copy
ActiveWorkbook.SaveAs Filename:="DestinationFile.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
ActiveWorkbook.Close
End Sub
Copying selected data from one to another, already existing file goes as follows:
Sub Export2()
' Select Data to Export from one file to another file
' Please note that both files must be open
Windows("SourceFile.xls").Activate
Sheets("DataSource").Select
Range("A1:Z9999").Select
ActiveSheet.Copy
' Paste exported data into the destination file
Windows("DestinationFile.xls").Activate
Sheets("DataTarget").Select
Range("A1").Select
ActiveSheet.Paste
End Sub
I hope this helps.....