Excel split string function

Simple VBA function to split strings into words (or strings):

Function TxtSplit(rngCell As Range, delim As String, nr As Long) As String
    Dim str As String
    Dim arr As Variant
    str = Trim(rngCell.Value)
    arr = Split(str, delim)
    TxtSplit = Trim(arr(nr - 1))
End Function

Sample usage:

=TxtSplit(B2;", ";1)

Share and Enjoy !


Leave a Reply

Your email address will not be published. Required fields are marked *