Function MyTrim(mystring) Dim start, Endpos start = 1 For i = 1 To Len(mystring) If Mid(mystring, i, 1) = vbTab Or Mid(mystring, i, 1) = " " Then start = i + 1 Else Exit For End If Next Endpos = Len(mystring) For i = Len(mystring) To 1 Step -1 If Mid(mystring, i, 1) = vbTab Or Mid(mystring, i, 1) = " " Then Endpos = i - 1 Else Exit For End If Next If (Endpos - start + 1) < 0 Then MyTrim = "" Exit Function End If MyTrim = Mid(mystring, start, Endpos - start + 1) End Function