Copy column data from one workbook to next empty column in another

daverunt

Well-known Member
Joined
Jul 9, 2009
Messages
1,946
Office Version
  1. 2013
Platform
  1. Windows
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?

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
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,215,541
Messages
6,125,413
Members
449,223
Latest member
Narrian

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top