So I'm reading a text file with extension .DAT from the file into excel. I assembled a method to do this from a few different posts. Here is the method which works:
Sub LoadFile()
Dim objFSO As Object
Dim objTF As Object
Dim strIn As String
Dim X
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTF = objFSO.OpenTextFile("C:\DL\DATATEST.DAT", 1)
strIn = objTF.readall
X = Split(strIn, vbNewLine)
Range("A1:A" & UBound(X) + 1) = Application.WorksheetFunction.Transpose(X)
objTF.Close
End Sub
But it stops working on a larger (11 MB) file. I get a Error 13 Type mismatch. It doesn't seem to be related to the data, because if I delete either the first or second half of all the data it works on either smaller file.
A line-by-line reading method is no good because that takes about 1 second per 500 lines and I've got upwards of 120k.
Sub LoadFile()
Dim objFSO As Object
Dim objTF As Object
Dim strIn As String
Dim X
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTF = objFSO.OpenTextFile("C:\DL\DATATEST.DAT", 1)
strIn = objTF.readall
X = Split(strIn, vbNewLine)
Range("A1:A" & UBound(X) + 1) = Application.WorksheetFunction.Transpose(X)
objTF.Close
End Sub
But it stops working on a larger (11 MB) file. I get a Error 13 Type mismatch. It doesn't seem to be related to the data, because if I delete either the first or second half of all the data it works on either smaller file.
A line-by-line reading method is no good because that takes about 1 second per 500 lines and I've got upwards of 120k.