![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Posts: 91
|
i have a text file which has more than 100k lines . I want to load that file into excel automatically.
is there a way? |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
|
Quote:
Why do you need to LOAD it into Excel? Would Access not be better? That's what Databases are made for.
__________________
"Have a good time......all the time" Ian Mac |
|
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,510
|
Excel is restricted to 65,536 rows.
Perhaps you need Access.
__________________
~Anne Troy |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: May 2002
Location: Montreal, Canada
Posts: 80
|
You should split the text file instead; then import the data...
Good Luck |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Try the following. You will have to use Text-to-Columns to parse the data after inporting.
Code:
Sub FileImport()
Dim ResultStr As String
Dim strFileName As String
Dim FileNum As Integer
Dim Counter As Long
strFileName = Application.GetOpenFilename(Title:="Import text file")
If strFileName = "" Then End
FileNum = FreeFile()
Open strFileName For Input As #FileNum
Application.ScreenUpdating = False
Workbooks.Add template:=xlWorksheet
Counter = 1
Do While Seek(FileNum) <= LOF(FileNum)
Line Input #FileNum, ResultStr
If Left(ResultStr, 1) = "=" Then
ActiveCell.Value = "'" & ResultStr
Else
ActiveCell.Value = ResultStr
End If
If ActiveCell.Row = 65535 Then
ActiveWorkbook.Sheets.Add
Else
ActiveCell.Offset(1, 0).Select
End If
Counter = Counter + 1
Loop
Close
End Sub
Jay |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|