How can I trim a string as follows?
MyText = "X1123-2"
so that MyText can become "X1123"
Hi Codebug. Bit more information would be helpful here...
Is the 'extra' bit
always separated by a dash, and is the dash
always present? If both of these are always true, you can use InStr to find the position of the dash, then Left to extract the portion of the string before the dash, or indeed both together:
Left(MyText, InStr(MyText, "-")-1)
If it is not always a dash that separates the other part, is it any punctuation character, or one of very few (such as a period '.')?
Need to know in order to make suggestions that will work always and not just sometimes. Easy to overlook the other cases - until the function fails when faced with no dash or a different separator!
-Stewart