Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Importing text file
I am importing a rather larger text file into excel, the entire thing will
not import onto one sheet. How do I import what did not fit onto the first sheet without reimporting what I just imported |
#2
|
|||
|
|||
You can slice it into several text files offline. Copy the code at the end
of this message into Notepad and save it with a .VBS extension. Double-click it to run. -- Jim Rech Excel MVP "Jillianno" wrote in message ... |I am importing a rather larger text file into excel, the entire thing will | not import onto one sheet. How do I import what did not fit onto the first | sheet without reimporting what I just imported Dim fso, fileSource, fileDest Dim fileSourceNoExt,fileSourceExt Dim lineCount, txtLine Dim wsh, tempFile Dim fileCount, dotPos Set fso = CreateObject("Scripting.FileSystemObject") Set wsh = CreateObject("WScript.Shell") ''Set sh = CreateObject("Shell.Application") tempFile = InputBox("Enter the full path and name of file", "Long Text File Parser") ''The following would not return a file, just a folder object, even tho with the 16896 it displays files ''tempFile = sh.BrowseForFolder(0, "Select a Folder", 16896, "c:\") If tempFile < "" Then If fso.FileExists(tempFile) Then dotPos = InStrRev(tempFile,".") If dotPos 0 Then fileSourceNoExt = Left(tempFile, dotPos-1) fileSourceExt = Mid(tempFile,dotPos) Else fileSourceNoExt = tempFile End If Set fileSource = fso.OpenTextFile(tempFile) Do While fileSource.AtEndOfLine < True If lineCount = 0 Then FileCount = FileCount + 1 Set fileDest = fso.CreateTextFile(fileSourceNoExt & FileCount & fileSourceExt, True) End If txtLine = fileSource.ReadLine fileDest.WriteLine txtLine lineCount = lineCount + 1 If lineCount = 65536 Then fileDest.Close lineCount = 0 End If Loop fileSource.Close wsh.Popup "Done!", 1, "Long Text File Parser" Else wsh.Popup "Source file not found", 2, "Long Text File Parser" End if End If |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do I enable "import text file" excel 2002? | Excel Discussion (Misc queries) | |||
Read Text File into Excel Using VBA | Excel Discussion (Misc queries) | |||
importing multiple text files URGENT!!! HELP | Excel Worksheet Functions | |||
importing multiple text files??? | Excel Discussion (Misc queries) | |||
Convert text file to MS_Excel | Excel Discussion (Misc queries) |