Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trim LAST 3 characters 5

Status
Not open for further replies.

eb24

Programmer
Dec 17, 2003
240
US
Please help.

I can't seem to figure this out! I have tried different combinations w/ no luck.

Basically I have an Excel sheet with a column full of varying length strings. All I want to do is take OFF the last 3 characters.

Thanks in advance for any advice.
 
In VBA use [tt]Right(str, 3)[/tt]; in the spreadheet use a formula [tt]=RIGHT(cell, 3)[/tt].

Hope this helps.

________________________________________
[hippy]Roger J Coult; Grimsby, UK
In the game of life the dice have an odd number of sides.
 
To remove the last 3 characters of string str:
Code:
str=Left(str,Len(str)-3)

Hope This Help
PH.
 
Sorry, mis-read your question: I was illuestrating how to get the last three characters. Your question seems to say; "How do I get all but the last three characters?":
Code:
   strExceptLast3 = Left(strToExtractFrom, Len(strToExtractFrom) - 3)
The formula is [tt]=LEFT(cell, LEN(cell) - 3)[/tt].
OK?

________________________________________
[hippy]Roger J Coult; Grimsby, UK
In the game of life the dice have an odd number of sides.
 
Woja, EB24 wants to remove the last 3 letters as i read the post, where as your solution will return the last 3:

To Trim the string, thus removing the last 3 characters try

VBA:
Code:
Left(str, Len(str)-3)
XL:
Code:
Left(cell, Len(cell)-3)

Hope this helps.






Leigh Moore
Solutions 4 MS Office Ltd
 
Hi eb24,

If your data is in A1 ..

=LEFT(A1,LEN(A1)-3)

.. or, if any of your cells might contain less than 4 characters, you would be better checking the length ..

=IF(LEN(A1)>3,LEFT(A1,LEN(A1)-3),"")

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Holy Cow!!!

I stepped away from my desk for a minute and I saw all these posts already!!! Thanks for all of your suggestions! It works perfectly!!
 
Tek-Tips .. faster than a speeding bullet [lol]

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top