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("A2
302").Select
Selection.Copy
Windows("attendance.xls").Activate
Range("A2
302").Select
ActiveSheet.Paste
'Branch2
Windows("av2.xls").Activate
Sheets("Working Time").Select
Range("A2
302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
ActiveWindow.SmallScroll Down:=280
Range("A303
603").Select
ActiveSheet.Paste
'Branch3
Windows("av3.xls").Activate
Sheets("Working Time").Select
Range("A2
302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A604
904").Select
ActiveSheet.Paste
'Branch4
Windows("av4.xls").Activate
Sheets("Working Time").Select
Range("A2
302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A905
1204").Select
ActiveSheet.Paste
'Branch6
Windows("av6a.xls").Activate
Sheets("Working Time").Select
Range("A2
302").Select
Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A1205
1502").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("A2

Selection.Copy
Windows("attendance.xls").Activate
Range("A2

ActiveSheet.Paste
'Branch2
Windows("av2.xls").Activate
Sheets("Working Time").Select
Range("A2

Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
ActiveWindow.SmallScroll Down:=280
Range("A303

ActiveSheet.Paste
'Branch3
Windows("av3.xls").Activate
Sheets("Working Time").Select
Range("A2

Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A604

ActiveSheet.Paste
'Branch4
Windows("av4.xls").Activate
Sheets("Working Time").Select
Range("A2

Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A905

ActiveSheet.Paste
'Branch6
Windows("av6a.xls").Activate
Sheets("Working Time").Select
Range("A2

Application.CutCopyMode = False
Selection.Copy
Windows("attendance.xls").Activate
Range("A1205

ActiveSheet.Paste
End Sub