When I ran the below code with a text file above 20 MB from my excel file, I get an Error showing "L = Val(X)" in yellow, and run-time error type mismatch 13 popped up.
First I posted it at https://www.excelforum.com/exc…ext-file.html#post5724130 but more help is required. Thanks in advance. -- Jai
Code
Sub Demo1()
W = Application.GetOpenFilename("Text Files,*.txt"): If W = False Then Exit Sub
[A1].CurrentRegion.Offset(1).Clear
L& = FreeFile
Open W For Input As #L
W = Split(Input(LOF(L), #L), vbCrLf)
Close #L
ReDim V(1 To UBound(W), 1)
For Each X In W
L = Val(X)
If X Like L & ". *" Then R& = R& + 1: V(R, 0) = L: V(R, 1) = Split(X, , 2)(1) Else V(R, 1) = V(R, 1) & vbLf & X
Next
With [A2:B2].Resize(R)
.HorizontalAlignment = xlLeft
.Value = V
End With
End Sub
Display More