Hello,
I am trying to import some data from other files and accordingly paste the data into a specific excel doc, so i can run additional flagging code against it.
To start with i have just recorded my actions, however i am sure that this code can be reduced.
My first question is is the first line of code (chdir...) necessary, or will the second line work ok on it's own?
Is it absolutely necessary to physically open the other document, as then i have to skip between docs all the time to get back to where i want to past the data and if i happen to have any other excel docs open at the time then this could cause me problems? I have already been given a more consise bit of copy - destination:= code which i think i can use, but i will still have to open & close all the docs every time.
My recorded code is as below:
OOch
I am trying to import some data from other files and accordingly paste the data into a specific excel doc, so i can run additional flagging code against it.
To start with i have just recorded my actions, however i am sure that this code can be reduced.
My first question is is the first line of code (chdir...) necessary, or will the second line work ok on it's own?
Is it absolutely necessary to physically open the other document, as then i have to skip between docs all the time to get back to where i want to past the data and if i happen to have any other excel docs open at the time then this could cause me problems? I have already been given a more consise bit of copy - destination:= code which i think i can use, but i will still have to open & close all the docs every time.
My recorded code is as below:
Code:
Sub OPenFiles()
ChDir "D:\02-EXCEL_DOCs"
Workbooks.Open Filename:="D:\02- EXCEL_DOCs\Gas_Aston_COT_PortAnlys.csv"
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A2:BA3435").Select
Selection.Copy
ActiveWindow.ActivatePrevious
ActiveSheet.Paste
Selection.End(xlDown).Select
Range("A3436").Select
End Sub
OOch