Public Function SeparateString(ByVal strWhole As String, _ Optional strDelimit As String = ",", _ Optional ynPreserveDelim As Boolean = False) As Variant ' Usage: vntChunks=SeparateString(String, Separator, preserve) ' String; the string to break into parts ' Separator; the character(s) that divide the parts, default ' is a comma ' preserve; include the delimiters in the output array? Dim tmpReturnValue() As String, intLocation As Integer, _ intSection As Integer ReDim Preserve tmpReturnValue(1) intLocation = 1 intSection = 1 Do While intLocation <= Len(strWhole) If (Mid(strWhole, intLocation, Len(strDelimit)) = strDelimit) _ And Len(tmpReturnValue(intSection)) > 0 _ Then intSection = intSection + 1 ReDim Preserve tmpReturnValue(intSection) If ynPreserveDelim Then tmpReturnValue(intSection) = strDelimit intSection = intSection + 1 ReDim Preserve tmpReturnValue(intSection) End If intLocation = intLocation + Len(strDelimit) Else tmpReturnValue(intSection) = tmpReturnValue(intSection) & _ Mid(strWhole, intLocation, 1) intLocation = intLocation + 1 End If Loop SeparateString = tmpReturnValue End Function