+ Reply to Thread
Results 1 to 17 of 17

Remove leading zeroes and trailing space

Hybrid View

  1. #1
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Remove leading zeroes and trailing space

    Hi,

    I have a cell that contains a number that is text.

    It has leading zeroes and a space after the last digit.

    "0011277370 "

    I would like to convert this to a number without the leading zeroes and the trailing space.

    There may be more, less or no leading zeroes in the numbers and may or may not have a trailing space.

    If a number has no leading zeroes and no trailing space then it should remain untouched.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Remove leading zeroes and trailing space

    text to column to make it general than do it again to make it back to text?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Remove leading zeroes and trailing space

    Quote Originally Posted by humdingaling View Post
    text to column to make it general than do it again to make it back to text?
    I don't think I understand the steps, text to column and do it again?

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,504

    Re: Remove leading zeroes and trailing space

    Assuming A1 contains number-stored-as- text
    Try:
    B1=A1+0

    Or: Add 0 into those cells:
    Copy a blank cell
    Choose range with number-stored-as text
    Paste special/Operation:Add/OK
    Quang PT

  5. #5
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Remove leading zeroes and trailing space

    Quote Originally Posted by bebo021999 View Post
    Assuming A1 contains number-stored-as- text
    Try:
    B1=A1+0

    Or: Add 0 into those cells:
    Copy a blank cell
    Choose range with number-stored-as text
    Paste special/Operation:Add/OK
    When I add zero to the text number I end up with #VALUE

  6. #6
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Remove leading zeroes and trailing space

    Attached is a small sample
    Attached Files Attached Files

  7. #7
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Remove leading zeroes and trailing space

    you can try with =--TRIM(A1) where A1 = 0011277370 - (with space on the end)

    btw. in your example on the end of string is not a space

    so try: =--TRIM(SUBSTITUTE(A2,CHAR(160),""))
    Last edited by sandy666; 12-12-2017 at 12:21 AM.

  8. #8
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Remove leading zeroes and trailing space

    Quote Originally Posted by sandy666 View Post
    you can try with =--TRIM(A1) where A1 = 0011277370 - (with space on the end)
    Still end up with #VALUE

  9. #9
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Remove leading zeroes and trailing space

    Quote Originally Posted by sandy666 View Post
    btw. in your example on the end of string is not a space

    so try: =--TRIM(SUBSTITUTE(A2,CHAR(160),""))
    Great that worked. Can you tell me what the 2 hyphens after the equals does please?

  10. #10
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Remove leading zeroes and trailing space

    re-read post above

  11. #11
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,504

    Re: Remove leading zeroes and trailing space

    Use this in B2:
    =SUBSTITUTE(Table1[@[PO Number]],CHAR(160),"")+0

  12. #12
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Remove leading zeroes and trailing space

    changing text number to number number (same as +0 or *1)

    If that takes care of your original question, & to say Thanks, please click on Add Reputtion (bottom left corner of the post of the person(s) who helped you)
    then select Thread Tools from the menu (top right corner of your thread) and mark this thread as SOLVED.
    If you did it already - ignore it.
    Thank you.

  13. #13
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,504

    Re: Remove leading zeroes and trailing space

    Sharing:
    "" is character with len = 0, means nothing

  14. #14
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Remove leading zeroes and trailing space

    Thanks guys (and gals).

  15. #15
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Remove leading zeroes and trailing space

    https://bettersolutions.com/excel/fu...s-operator.htm
    The double minus (--) can be used to transform TRUE and FALSE values into there corresponding 1 and 0 equivalents

    without it it doesnt remove the leading 0's

  16. #16
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Remove leading zeroes and trailing space

    @bebo
    "" = empty string
    nothing is null

  17. #17
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Remove leading zeroes and trailing space

    thanks for rep(s) (bebo & kerspash) and mark thread solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to remove all leading and trailing colons (;) from a text?
    By excelhelp2045 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-28-2015, 01:19 AM
  2. [SOLVED] Remove 9 trailing zeroes from number in cell
    By Melissa Camp in forum Excel General
    Replies: 2
    Last Post: 09-11-2014, 04:22 PM
  3. [SOLVED] Remove leading and trailing spaces in a cell?
    By LF_CC in forum Excel General
    Replies: 4
    Last Post: 12-05-2013, 03:12 PM
  4. How to remove trailing SPACE from Cell value ?
    By zerodegree in forum Excel General
    Replies: 6
    Last Post: 02-04-2013, 04:15 AM
  5. Replies: 5
    Last Post: 10-10-2012, 06:04 AM
  6. VBA to add leading o's and trailing space for fixed length SIR fields
    By Zyphon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-03-2008, 08:51 AM
  7. (in)definite article and leading/trailing space remover needed
    By KHashmi316 in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 06-16-2005, 01:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1