I have a text file that I am unable to import into excel. The file is over 2000 pages long when I load it into word. Is there a way to save this text file into shorter text files - say 20 files of about 100 pages? How would I do this?
A 2000 'page' file would probably hold around 140,000 lines of data, assuming no manual page breaks.
An Excel worksheet can hold up to 65536 lines per worksheet.
You could use a macro to import the file, adding a new sheet every 65536 rows, but you might find it quicker to manually split the file into three parts and open each part as a .csv or .txt file.
This would import a large tex file into excel
Sub LargeFileImport()
Dim ResultStr As String
Dim FileName As String
Dim FileNum As Integer
Dim Counter As Double
FileName = InputBox("Please enter the Text File's name, e.g. S:\Revenue\Straus\BATCHOCCMUM121002.txt")
If FileName = "" Then End
FileNum = FreeFile()
Open FileName For Input As #FileNum
Application.ScreenUpdating = False
Workbooks.Add template:=xlWorksheet
Counter = 1
Do While Seek(FileNum) <= LOF(FileNum)
Application.StatusBar = "Importing Row " & _
Counter & " of text file " & FileName
Line Input #FileNum, ResultStr
If Left(ResultStr, 1) = "=" Then
ActiveCell.Value = "'" & ResultStr
Else
ActiveCell.Value = ResultStr
End If
If ActiveCell.row = 65536 Then
ActiveWorkbook.Sheets.Add
Else
ActiveCell.Offset(1, 0).Select
End If
Counter = Counter + 1
Loop
Close
Application.StatusBar = False
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.