G
Guest
I record a macro code to copy the data from the workbook to another workbook
( av1.xls, av2.xls .. etc.. to attendance.xls) but the problem is I have to
open first all the excel workbook before i can run the macro... anyone can
make this code simple and can auto open all the excel files and after the
copying complete it will close and just the attendance.xls will remain open.
Thanks a lot...
Sub Copy ()
' Branch1
Windows("av1.xls").Activate
Sheets("Working Time").Select
Range("A2302").Select
Selection.Copy
Windows("attendance.xls").Activate
Range("A2302").Select
ActiveSheet.Paste
'Branch2
Windows("av2.xls").Activate
Sheets("Working Time").Select
Range("A2302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
ActiveWindow.SmallScroll Down:=280
Range("A303603").Select
ActiveSheet.Paste
'Branch3
Windows("av3.xls").Activate
Sheets("Working Time").Select
Range("A2302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A604904").Select
ActiveSheet.Paste
'Branch4
Windows("av4.xls").Activate
Sheets("Working Time").Select
Range("A2302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A9051204").Select
ActiveSheet.Paste
'Branch6
Windows("av6a.xls").Activate
Sheets("Working Time").Select
Range("A2302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A12051502").Select
ActiveSheet.Paste
End Sub
( av1.xls, av2.xls .. etc.. to attendance.xls) but the problem is I have to
open first all the excel workbook before i can run the macro... anyone can
make this code simple and can auto open all the excel files and after the
copying complete it will close and just the attendance.xls will remain open.
Thanks a lot...
Sub Copy ()
' Branch1
Windows("av1.xls").Activate
Sheets("Working Time").Select
Range("A2302").Select
Selection.Copy
Windows("attendance.xls").Activate
Range("A2302").Select
ActiveSheet.Paste
'Branch2
Windows("av2.xls").Activate
Sheets("Working Time").Select
Range("A2302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
ActiveWindow.SmallScroll Down:=280
Range("A303603").Select
ActiveSheet.Paste
'Branch3
Windows("av3.xls").Activate
Sheets("Working Time").Select
Range("A2302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A604904").Select
ActiveSheet.Paste
'Branch4
Windows("av4.xls").Activate
Sheets("Working Time").Select
Range("A2302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A9051204").Select
ActiveSheet.Paste
'Branch6
Windows("av6a.xls").Activate
Sheets("Working Time").Select
Range("A2302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A12051502").Select
ActiveSheet.Paste
End Sub