'This function strips the next field off a string 'It is used like this 'First time round, send through the text to be stripped, along with the delimiter 'Thereafter, simply call the function without providing any parameters, and the 'function will keep stripping the string, using the same delimiter 'eg suppose you want to strip the string Fred=123|456|789 'you'd get the first field with Field1 = StripDelimiter(Fred,"|") which would return 123 'Field2 = StripDelimiter would return 456, and Field3 = StripDelimiter would return 789 Function StripDelimiter(Optional Txt As String, Optional Delim As String) As String 'remember the string from the last visit 'this is so we can keep stripping the same string until it's finished Static tText As String, tDelimiter As String 'if user has provided a string, put it in tText, and check for the delimiter If Txt <> "" Or Delim <> "" Then tText = Txt If Delim <> "" Then tDelimiter = Delim Else 'use comma if nothing provided tDelimiter = "," End If End If 'strip next field off string Dim u As Integer 'find next delimiter u = InStr(tText, tDelimiter) If u > 0 Then 'strip it off, truncate the string StripDelimiter = Left$(tText, u - 1) tText = Mid$(tText, u + 1) Else 'if no delimiter found, this must be the last field, erase the string StripDelimiter = tText tText = "" End If End Function