![]() |
importing multiple text files into individual worksheets in workbook
Hi I've searched through group and haven't quite found an answer for my
use. I have multiple individual text files, that contain simple text. I want to import them into 1 workbook each as a seperate worksheet.Each text file,single column, and each text line as a seperate row in sheet. Thanks Guy |
importing multiple text files into individual worksheets in workbo
Sub ImportFiles()
Dim sPath as String, sName as String Dim bk as Workbook sPath = "C:\MyTextFiles\" sName = dir(sPath & "*.txt") do while sname < "" set bk = workbooks.Open(sPath & sname) bk.worksheets(1).Move After:= _ thisworkbook.worksheets( _ thisworkbook.worksheets.count) sname = Dir() Loop End sub -- Regards, Tom Ogilvy " wrote: Hi I've searched through group and haven't quite found an answer for my use. I have multiple individual text files, that contain simple text. I want to import them into 1 workbook each as a seperate worksheet.Each text file,single column, and each text line as a seperate row in sheet. Thanks Guy |
importing multiple text files into individual worksheets in wo
Tom,
How could you use this to work with delimited data? I have multiple .chr files where the string is delimited by " and the field by , that I'd like to get into individual sheets in one workbook. I tried to mess with your code, but can't figure it out. Thanks! "Tom Ogilvy" wrote: Sub ImportFiles() Dim sPath as String, sName as String Dim bk as Workbook sPath = "C:\MyTextFiles\" sName = dir(sPath & "*.txt") do while sname < "" set bk = workbooks.Open(sPath & sname) bk.worksheets(1).Move After:= _ thisworkbook.worksheets( _ thisworkbook.worksheets.count) sname = Dir() Loop End sub -- Regards, Tom Ogilvy " wrote: Hi I've searched through group and haven't quite found an answer for my use. I have multiple individual text files, that contain simple text. I want to import them into 1 workbook each as a seperate worksheet.Each text file,single column, and each text line as a seperate row in sheet. Thanks Guy |
All times are GMT +1. The time now is 02:57 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com