• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

RTRIM, LTRIM excel

Hiren Parekh

New Member
Hello,
How would you perform an RTrim and LTrim in excel?

I am trying do this for a bunch of people names but do not want to use the trim function since it will trim spaces in between the first name, middle initial and the last name.

Thank you.
 
I suspect that you do want the TRIM function but have misinterpreted what it does.
Internal spaces are not removed but, rather, are reduced to a single space. So, unless counting consecutive internal spaces is a key part of your algorithm, you will have what you need.
 
Otherwise to mimic what it is doing, you need to create an UDF like below.
Code:
Public Function ufLTRIM(strInput As String) As String
ufLTRIM = LTRIM(strInput)
End Function

Public Function ufRTRIM(strInput As String) As String
ufRTRIM = RTrim(strInput)
End Function

And then use like normal formula
=ufLTRIM(A1)
 
Back
Top