How to remove trailing two 0's from a string datatype column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ncsthbell
    New Member
    • May 2007
    • 167

    #1

    How to remove trailing two 0's from a string datatype column

    I have a string datatype column which contains values such as '1841000'. The value should be '18410'. I have tried the following:
    Replace(RTrim(R eplace(MyValue, "0", " ")), " ", "0")

    The problem is that this is replacing all trailing 0's and I wind up with '1841'.

    Can you tell me what I can use to only truncate or remove the last 2 0's in my value? Also, the length of the column varies. I have been trying various functions all morning and have not been able to do this successfully.

    Thanks for any help I can get!!
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Is this for Excel ?
    If so, You can use the function=

    Code:
    Public Function Cut_End(CELLADDRESS As Range) As String
       Cut_End = Left(CELLADDRESS, Len(CELLADDRESS) - 2)
    End Function
    If it's VB, you can use the same code=

    Code:
    text1.text = left(text1.text, len(text1.text)-2)

    Comment

    • ncsthbell
      New Member
      • May 2007
      • 167

      #3
      Remove trailing 0's

      Thanks SO much! This worked perfectly!

      Comment

      Working...