![]() |
Import all txt files macro
Hi
Can you tell me how the macro looks like if I would like to import to Excel spreadhseet all txt files from specific folder starting row 1? -- Greatly appreciated Eva |
Import all txt files macro
Eva,
This copies the contents of all text files in the root of C to column A of the active sheet. Change the path to suit your needs Sub LoopThroughDirectory() Dim x As Long Application.DisplayAlerts = False x = 1 MyPath = "C:\" 'Change to suit Fnam = Dir(MyPath & "*.txt") Do While Fnam < "" Open MyPath & Fnam For Input As #1 Do While Not EOF(1) Input #1, Line$ ActiveSheet.Cells(x, 1).Value = Line$ x = x + 1 Loop Close #1 Fnam = Dir() Loop Application.DisplayAlerts = True End Sub Mike "Eva" wrote: Hi Can you tell me how the macro looks like if I would like to import to Excel spreadhseet all txt files from specific folder starting row 1? -- Greatly appreciated Eva |
Import all txt files macro
Hi Eva
See also http://www.rondebruin.nl/csv.htm Or http://www.rondebruin.nl/txtcsv.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Eva" wrote in message ... Hi Can you tell me how the macro looks like if I would like to import to Excel spreadhseet all txt files from specific folder starting row 1? -- Greatly appreciated Eva |
Import all txt files macro
Works fine :) Thanks
-- Greatly appreciated Eva "Mike H" wrote: Eva, This copies the contents of all text files in the root of C to column A of the active sheet. Change the path to suit your needs Sub LoopThroughDirectory() Dim x As Long Application.DisplayAlerts = False x = 1 MyPath = "C:\" 'Change to suit Fnam = Dir(MyPath & "*.txt") Do While Fnam < "" Open MyPath & Fnam For Input As #1 Do While Not EOF(1) Input #1, Line$ ActiveSheet.Cells(x, 1).Value = Line$ x = x + 1 Loop Close #1 Fnam = Dir() Loop Application.DisplayAlerts = True End Sub Mike "Eva" wrote: Hi Can you tell me how the macro looks like if I would like to import to Excel spreadhseet all txt files from specific folder starting row 1? -- Greatly appreciated Eva |
Import all txt files macro
Thank you
-- Greatly appreciated Eva "Ron de Bruin" wrote: Hi Eva See also http://www.rondebruin.nl/csv.htm Or http://www.rondebruin.nl/txtcsv.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Eva" wrote in message ... Hi Can you tell me how the macro looks like if I would like to import to Excel spreadhseet all txt files from specific folder starting row 1? -- Greatly appreciated Eva . |
All times are GMT +1. The time now is 06:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com