Hi Brett,
I would think that the native text import would be faster, but you could try a Regular Expression to delimit the results and test speed.
Option Explicit
Sub Main()
Dim strFullName As String
Dim ArrayRes As Variant
strFullName = "G:\2010\2010-06-30\bdl004\vbax33155#7_example\Copy of example.txt"
ArrayRes = RetArrays(strFullName, 5)
MsgBox ArrayRes(4, 1) & vbTab & ArrayRes(4, 2) & vbTab & ArrayRes(4, 3)
End Sub
Function RetArrays(FFName As String, NoLines2Skip As Long) As Variant
Dim FSO As Object ' FileSystemObject
Dim fsoTFile As Object ' TextStream
Dim REX As Object ' RegExp
Dim rexMatches As Object ' MatchCollection
Dim strRaw As String
Dim i As Long
Dim x As Long
Dim y As Long
Dim aryLayedOver As Variant
Dim aryTransposed As Variant
ReDim aryLayedOver(1 To 3, 1 To 500000)
Set REX = CreateObject("VBScript.RegExp")
With REX
.Global = False
.MultiLine = False
'2004-10-01 00:00:00 0
.Pattern = "(\b[0-9]{4}-[0-9]{2}-[0-9]{2}\b)" & _
"(\ |\t)" & _
"([0-9]{2}\:[0-9]{2}\:[0-9]{2})" & _
"(\ |\t)" & _
"([0-9]*)"
End With
Set FSO = CreateObject("Scripting.FileSystemObject")
Set fsoTFile = FSO.OpenTextFile(FFName, 1, False, &HFFFFFFFE)
With fsoTFile
For i = 1 To NoLines2Skip
.SkipLine
Next
i = 0
Do While Not .AtEndOfStream
strRaw = .ReadLine
If REX.Test(strRaw) Then
Set rexMatches = REX.Execute(strRaw)
i = i + 1
aryLayedOver(1, i) = CDate(rexMatches(0).SubMatches(0))
aryLayedOver(2, i) = CDate(rexMatches(0).SubMatches(2))
aryLayedOver(3, i) = CLng(rexMatches(0).SubMatches(4))
End If
Loop
.Close
End With
'// If you wanted to leave the array as 3 rows * x columns, we could trim to fit here. //
' ReDim Preserve aryLayedOver(1 To 3, 1 To i)
ReDim aryTransposed(1 To i, 1 To 3)
For x = 1 To i
For y = 1 To 3
aryTransposed(x, y) = aryLayedOver(y, x)
Next
Next
RetArrays = aryTransposed
End Function
Mark