Dears,
Is it possible to speed-up my code?
Sub test()
Dim fn As String, txt As String, delim As String, a() As String
Dim i As Long, ii As Long, iii As Long, n As Long, x, y
fn = "C:\Users\bruno\Desktop\Airports.txt" ' ?Change here (File Path)
delim = "|" ' ?Change here (delimiter)
temp = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
x = Split(temp, vbCrLf)
ReDim a(1 To UBound(x) + 1, 1 To 15)
For i = 0 To UBound(x)
If InStr(1, x(i), "SBKP", 1) > 0 Then
n = n + 1
y = Split(x(i), delim)
For m = 0 To UBound
a(n, m + 1) = y(m)
Next
Do While InStr(1, x(i + 1), "R|", 1) > 0
n = n + 1:
y = Split(x(i + 1), delim)
For ii = 0 To UBound
a(n, ii + 1) = y(ii)
Next
i = i + 1
Loop
End If
Next
End Sub
Is it possible to speed-up my code?
Sub test()
Dim fn As String, txt As String, delim As String, a() As String
Dim i As Long, ii As Long, iii As Long, n As Long, x, y
fn = "C:\Users\bruno\Desktop\Airports.txt" ' ?Change here (File Path)
delim = "|" ' ?Change here (delimiter)
temp = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
x = Split(temp, vbCrLf)
ReDim a(1 To UBound(x) + 1, 1 To 15)
For i = 0 To UBound(x)
If InStr(1, x(i), "SBKP", 1) > 0 Then
n = n + 1
y = Split(x(i), delim)
For m = 0 To UBound
a(n, m + 1) = y(m)
Next
Do While InStr(1, x(i + 1), "R|", 1) > 0
n = n + 1:
y = Split(x(i + 1), delim)
For ii = 0 To UBound
a(n, ii + 1) = y(ii)
Next
i = i + 1
Loop
End If
Next
End Sub