LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default import from text file

Another alternative is to run this code: it opens the original file and
creates sequentially numbered sub-files, which you can import to Excel.
Note you'll need to adjust the file path and possibly the TXT file
extension. The sub-files are called "Target" in this code, which you
can change- but you'll need to change all instances within the code.
You can adjust the number of rows per file from 60,000 to whatever is
appropriate. Enjoy!

Sub Import_Trim()
Dim Lyne As String
Dim FileCount As Byte, K As Byte
FileCount = 1

Open "c:\directory path\Source File Name.txt" For Input As #1
Open "c:\directory path\Target1.txt" For Output As #2

On Error Resume Next
Do While Not EOF(1)
For K = 1 To 60000
Line Input #1, Lyne
Print #2, Lyne
Next K

Close #2
FileCount = FileCount + 1
Open "c:\directory path\Target" & FileCount & ".txt" For Output As #2
Loop

Close #1
Close #2
MsgBox "Done."
End Sub

 
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
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
How to import a text file to Excel treating all input content are in string. Chittu Excel Discussion (Misc queries) 1 July 22nd 05 06:37 AM
Formulas dealing with text data Bagia Excel Worksheet Functions 6 June 20th 05 10:29 PM
how do I enable "import text file" excel 2002? jw_schmid Excel Discussion (Misc queries) 2 February 9th 05 10:39 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM


All times are GMT +1. The time now is 12:05 AM.

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

About Us

"It's about Microsoft Excel"