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

daverunt

Well-known Member
Joined
Jul 9, 2009
Messages
1,891
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
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Watch MrExcel Video

Forum statistics

Threads
1,127,395
Messages
5,624,487
Members
416,031
Latest member
Omega67

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
Top