![]() |
Import n .csv data
I've been trying to work out my problem from bits of other peoples answers
without success. I have n number of .csv files in a folder. I need to import into an Excel file a specific column of data from each file, then delete the file once it's complete. The column range in the .csv file is always the same (C2:C54). I'm very new to VBA & I am struggling. Can anyone help? |
Import n .csv data
Dim sh as Workshet
Dim sName as String Dim rng as Range Dim bk as Workbook set sh = Activesheet sName = Dir("C:\Myfolder\*.csv") do while sName < "" set bk = Workbooks.Open( "C:\MyFolder\" & sName) set rng = bk.Worksheets(1).Range("C2:C54") rng.copy destination:=sh.Cells(1,256).End(xltoLeft)(1,2) bk.close SaveChanges:=False sName = Dir() Loop Kill "C:\MyFolder\*.csv" -- Regards, Tom Ogilvy "Baldyman" wrote in message ... I've been trying to work out my problem from bits of other peoples answers without success. I have n number of .csv files in a folder. I need to import into an Excel file a specific column of data from each file, then delete the file once it's complete. The column range in the .csv file is always the same (C2:C54). I'm very new to VBA & I am struggling. Can anyone help? |
Import n .csv data
Tom, thanks a bundle. I realise now I've been looking for the hard way to do
it all weekend! Many thanks again, it works a treat "Tom Ogilvy" wrote: Dim sh as Workshet Dim sName as String Dim rng as Range Dim bk as Workbook set sh = Activesheet sName = Dir("C:\Myfolder\*.csv") do while sName < "" set bk = Workbooks.Open( "C:\MyFolder\" & sName) set rng = bk.Worksheets(1).Range("C2:C54") rng.copy destination:=sh.Cells(1,256).End(xltoLeft)(1,2) bk.close SaveChanges:=False sName = Dir() Loop Kill "C:\MyFolder\*.csv" -- Regards, Tom Ogilvy "Baldyman" wrote in message ... I've been trying to work out my problem from bits of other peoples answers without success. I have n number of .csv files in a folder. I need to import into an Excel file a specific column of data from each file, then delete the file once it's complete. The column range in the .csv file is always the same (C2:C54). I'm very new to VBA & I am struggling. Can anyone help? |
All times are GMT +1. The time now is 05:30 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com