anuclearbomb
New Member
- Joined
- Apr 14, 2013
- Messages
- 6
Hello everyone,
Just started Vba yesterday so please bear with me :D
I have a project that needs to input data from many small files into a master file, lets call the master file ABC here. Inside the small files, the format are exactly the same.
However the name of the small files are all different and the number of files I have to process is not fixed too.
I wrote this:
Sub Test()
Do
ActiveWindow.Activate
Sheets("2. Particulars").Select
Range("D4").Copy
Windows("ABC.xls").Activate
Range("D" & Rows.Count).End(xlUp).Offset(2).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Windows("ABC.xls").ActivatePrevious
ActiveWindow.Close (savechanges = False)
ActiveWindow.ActivateNext
Loop Until Application.Windows.Count = 1
End Sub
My idea is to open ABC and all the small files at the same time. Manually activate a small file and run macro.
My problem now is that the first small file's result is displayed twice, and another random small file's data is omitted.
If I open 1 small file, run the script and close small file, then do the same manually for the other small files, everything works.
I know this is a longgggg message, but please help
Just started Vba yesterday so please bear with me :D
I have a project that needs to input data from many small files into a master file, lets call the master file ABC here. Inside the small files, the format are exactly the same.
However the name of the small files are all different and the number of files I have to process is not fixed too.
I wrote this:
Sub Test()
Do
ActiveWindow.Activate
Sheets("2. Particulars").Select
Range("D4").Copy
Windows("ABC.xls").Activate
Range("D" & Rows.Count).End(xlUp).Offset(2).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Windows("ABC.xls").ActivatePrevious
ActiveWindow.Close (savechanges = False)
ActiveWindow.ActivateNext
Loop Until Application.Windows.Count = 1
End Sub
My idea is to open ABC and all the small files at the same time. Manually activate a small file and run macro.
My problem now is that the first small file's result is displayed twice, and another random small file's data is omitted.
If I open 1 small file, run the script and close small file, then do the same manually for the other small files, everything works.
I know this is a longgggg message, but please help