Code:
'Here's the split function:
Public Function Split(ByVal sIn As String, Optional sDelim As String, Optional nLimit As Long = -1, Optional bCompare As VbCompareMethod = vbBinaryCompare) As Variant
Dim sRead As String, sOut() As String, nC As Integer
If sDelim = "" Then
Split = sIn
End If
sRead = ReadUntil(sIn, sDelim, bCompare)
Do
ReDim Preserve sOut(nC)
sOut(nC) = sRead
nC = nC + 1
If nLimit <> -1 And nC >= nLimit Then Exit Do
sRead = ReadUntil(sIn, sDelim)
Loop While sRead <> ""
ReDim Preserve sOut(nC)
sOut(nC) = sIn
Split = sOut
End Function
'But this one (made by Iain) is a lot faster, especially for larger strings:
Private Sub Mysplit(Source, searchs As String, ByRef Arr() As String)
Dim pos As Long, pos2 As Long, x As Long
pos = 0
If Right(Source, Len(searchs)) = searchs Then
Source = Mid$(Source, 1, Len(Source) - Len(searchs))
End If
Do
pos = InStr(pos + 1, Source, searchs, vbTextCompare)
If pos = 0 Then Exit Do
ReDim Preserve Arr(x)
Arr(x) = Mid(Source, pos + 1, pos + Len(searchs) - 2)
x = x + 1
Loop
End Sub