Showing posts with label Split. Show all posts
Showing posts with label Split. Show all posts

Sep 2, 2008

How Use Split Function in Excel 97 (UDF Split97)

Function Split97(OriStr, Optional OptStr As String  = ",")
Dim GetText    As String
Dim GetPoss    As Double
Dim MidStr     As Variant
Dim AnsStr     As Variant
ReDim MidStr(0 To Len(CStr(OriStr)))
Dim i As Double, j As  Double
GetText = OriStr
For i = 1 To Len(CStr(OriStr))
GetPoss = InStr(GetText, OptStr)
     If GetPoss > 0 Then
          MidStr(j) = Left(GetText, GetPoss - 1)
          GetText = Mid(GetText, GetPoss + 1)
          j = j + 1
     Else
          MidStr(j) = Mid(GetText, GetPoss + 1)
          Exit For
     End If
Next
ReDim AnsStr(0 To j)
For i = 0 To j
     AnsStr(i) = MidStr(i)
Next
Split97 = AnsStr
End Function
Locations of visitors to this page