Hi,
I am just starting a new macro and I am trying to copy a single column of data from a folder of csv files (ResultFile) into the first empty column in a newly created workbook RptTemplate.
I wanted to use the format 'Copy Destination:-' inside a loop to do this.
Is there a one liner that can do it or will I need to find the last column and use that method?
I am just starting a new macro and I am trying to copy a single column of data from a folder of csv files (ResultFile) into the first empty column in a newly created workbook RptTemplate.
I wanted to use the format 'Copy Destination:-' inside a loop to do this.
Is there a one liner that can do it or will I need to find the last column and use that method?
Code:
Set RptTemplate = Workbooks.Add
Sheets("Sheet1").Name = "Report"
'Add the data sheet.
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "Data"
'''''''''''''''There will be a loop here to go through several csv files
'Open the csv Result File and copy column B5 down into RptTemplate to next empty column
Workbooks.Open ResultFile
Set CSVFile = ActiveWorkbook
Range("B5", Range("B5").End(xlDown)).Copy Destination:=RptTemplate.Sheets("Data").Range("A2") '----------------------- to first empty column
''''''''''''end loop