Some points to note: -
- Reading a 300MB file in a single go is a big ask, I'm surprised if it ever worked and not surprised it failed
- In my experience, an Excel file over 80-90 MB in size is difficult to work with, unless you absolutely have to, I would recommend splitting the result into workbooks (Excel files) and not sheets (worksheets within a single workbook).
It is cumbersome but this would need to be done one line at a time. The below is an example of opening the text file and reading X number of lines into separate workbooks.
Public Sub Sample()
Dim ObjFSO As Object
Dim ObjTS As Object
Dim AryData() As String
Dim LngDataRow As Long
Dim LngWkbkNo As Long
Dim WkBk As Workbook
Dim WkSht As Worksheet
'This dictates how many rows should be in each workbook
ReDim AryData(100000)
'Open then file
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set ObjTS = ObjFSO.OpenTextFile(ThisWorkbook.Path & "\SampleFile.txt")
'Process each line
Do Until ObjTS.AtEndOfStream
'If we have filled up our array then we need to output it
If LngDataRow > UBound(AryData, 1) Then
LngWkbkNo = LngWkbkNo + 1
Set WkBk = Application.Workbooks.Add
Set WkSht = WkBk.Worksheets(1)
WkSht.Range("A1:A" & UBound(AryData, 1) + 1) = AryData
Set WkSht = Nothing
WkBk.SaveAs ThisWorkbook.Path & "\" & Right("000" & CStr(LngWkbkNo), 3) & ".xlsx"
WkBk.Close 0
Set WkBk = Nothing
'Reset the array and go back to the start
ReDim AryData(UBound(AryData, 1))
LngDataRow = 0
End If
'Add a line from the file into the array
AryData(LngDataRow) = ObjTS.ReadLine
LngDataRow = LngDataRow + 1
DoEvents
Loop
Set ObjTS = Nothing
Set ObjFSO = Nothing
'Put the final lines into a file
If AryData(0) <> "" Then
LngWkbkNo = LngWkbkNo + 1
Set WkBk = Application.Workbooks.Add
Set WkSht = WkBk.Worksheets(1)
WkSht.Range("A1:A" & UBound(AryData, 1) + 1) = AryData
Set WkSht = Nothing
WkBk.SaveAs ThisWorkbook.Path & "\" & Right("000" & CStr(LngWkbkNo), 3) & ".xlsx"
WkBk.Close 0
Set WkBk = Nothing
End If
MsgBox "Done"
End Sub