Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Multiple txt files import

I need to regularly move all text files from a directory into a database
(Excel97). All text files are exactly the same number of rows but not in
length of rows and the data within needs to be appended to a single table
(every row is a field in the record). Is there a way to loop through all
..txt files from a directory and run a TransferText that appends the data
from each into the target table?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiple txt files import

This should work:-

Sub Macro1()
Workbooks.Open Filename:= "filename.txt"
Selection.Copy
Windows("Book1").Activate
Range("A1").Select
ActiveSheet.Paste
MsgBox ("Complete")
End Sub

Just put the path and filename of "filename.txt" and the current
workbooks name in "Book1"


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Multiple txt files import

Not completely,

I have 10 .txt files in a directory. Each file has 10 lines. I want to put
each line in a cells where every row is the contect of one txt file.



"ianripping " schreef in bericht
...
This should work:-

Sub Macro1()
Workbooks.Open Filename:= "filename.txt"
Selection.Copy
Windows("Book1").Activate
Range("A1").Select
ActiveSheet.Paste
MsgBox ("Complete")
End Sub

Just put the path and filename of "filename.txt" and the current
workbooks name in "Book1"


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiple txt files import

I'm not sure I understood :(, but following can work...Each .txt file is
pasted in single row...I had similar problem with 1500 .xls files. I
didn't test following code, but I hope it can work...

Sub Macro1()

For i = 1 to 10
Workbooks.Open Filename:= "File" & i & ".txt"
Selection.Copy
Windows("Book1").Activate
Range("A1").Select
ActiveSheet.Pastespecial := xlvalues, transpose:= true
Activecell.offset(1,0).select
Workbooks("File" & i & ".txt").close
Next i
MsgBox ("Complete")

End Sub


---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiple txt files import

-this example is what I have been looking for.
1) The code below will not run & do not understand the line tha
fails.
2) Will this load all text files into one sheet, in one row after th
next?

Sub Macro1()

For i = 1 To 10
Workbooks.Open Filename:="File" & i & ".txt"
Selection.Copy
Windows("Book1").Activate
Range("A1").Select

--ActiveSheet.PasteSpecial := xlvalues, transpose:= true


ActiveCell.Offset(1, 0).Select
Workbooks("File" & i & ".txt").Close
Next i
MsgBox ("Complete")

End Sub

Thanks

--
Message posted from http://www.ExcelForum.com

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 Multiple XML Files into Excel Mungkol Excel Discussion (Misc queries) 3 January 22nd 09 01:37 PM
import multiple csv files into excel 2007 Annie - torston Excel Discussion (Misc queries) 1 January 15th 09 06:24 AM
Import multiple text files (Macro) Thr33of4 Excel Discussion (Misc queries) 0 September 19th 06 02:19 AM
Import multiple text files into excel Wally Steadman[_2_] Excel Programming 1 November 15th 03 04:14 PM
Import multiple files macro can't find files Steven Rosenberg Excel Programming 1 August 7th 03 01:47 AM


All times are GMT +1. The time now is 11:36 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"