Sandeep Warrier
Well-known Member
- Joined
- Oct 31, 2008
- Messages
- 2,678
Hey All,
Looking to extract the last 3 words in a string
gives the last 2 words preceded by 99 spaces. It isn't letting me put a TRIM() before it. When I try to put a TRIM(), it says formula incorrect. Also, when I try to extend this to include the 3rd last word, it gives the same error, Formula Incorrect.
I'm sure there would be an easier way to do this. Even VBA would help.
Regards,
Sandeep.
Looking to extract the last 3 words in a string
Code:
RIGHT(SUBSTITUTE(LEFT(D21,LEN(D21)-LEN(TRIM(RIGHT(SUBSTITUTE(TRIM(D21)," ",REPT(" ",99)),99)))-1)," ",REPT(" ",99)),99)&" "&TRIM(RIGHT(SUBSTITUTE(D21," ",REPT(" ",99)),99))
gives the last 2 words preceded by 99 spaces. It isn't letting me put a TRIM() before it. When I try to put a TRIM(), it says formula incorrect. Also, when I try to extend this to include the 3rd last word, it gives the same error, Formula Incorrect.
I'm sure there would be an easier way to do this. Even VBA would help.
Regards,
Sandeep.