Removing Prefix and Suffix of a Text String

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
How can I remove the 1st two characters and the last character of a text
string which is of dynamic string length? (that is my text string can be of
different length).

Example:
PM1236-5685Z --------> 1236-5685
HP25899-21158Y --------> 25899-21158
HM2125-3214Z --------> 2125-3214
HB125-256Y ---------> 125-256

Thanks and Regards,
Ringo
 
Thanks Dave. I understand that the '3' after MID(A1,..... means starts at 3rd
position but I dont get what '-3' after MID(A1,3,LEN(A1)..... means?
Please enlighten me?
 
"LEN(A1)" will return the # of char in the string

The "-3" in "LEN(A1)-3" in the MID(...) is an arithmetic
adjustment to "LEN(A1)" that will avoid returning
the *last char* - which gives what is wanted

Thought it might be good also to throw in TRIM() in Dave's formula, to take
care of any leading & trailing spaces ..:
: =MID(TRIM(A1),3,LEN(TRIM(A1))-3)
 
Back
Top