Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Eva Eva is offline
external usenet poster
 
Posts: 197
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,123
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Eva Eva is offline
external usenet poster
 
Posts: 197
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Eva Eva is offline
external usenet poster
 
Posts: 197
Default 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

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import Several .txt Files Renee B. Excel Discussion (Misc queries) 2 October 3rd 07 07:06 PM
Import multiple text files (Macro) Thr33of4 Excel Discussion (Misc queries) 0 September 19th 06 02:19 AM
problem with import files by excel macro Raven Excel Discussion (Misc queries) 0 January 20th 06 08:23 AM
problem with import files by excel macro Raven Excel Discussion (Misc queries) 0 January 20th 06 08:22 AM
Import CSV files using Macro Mintz87 New Users to Excel 3 August 29th 05 09:48 PM


All times are GMT +1. The time now is 09:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"