View Single Post
  #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