+ Reply to Thread
Results 1 to 12 of 12

Formula to remove 0's from part of a text string

  1. #1
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Formula to remove 0's from part of a text string

    Morning all,

    I have some text strings and I need to remove the 0's from the start of the string to the penultimate character.

    E.g. in cell A1 I have the text 'TS01 to TS20' and I would like to convert it to 'TS1 to TS20'.

    Thanks in advance,

    Snook

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Formula to remove 0's from part of a text string

    Do you have all the text ('TS01 to TS20') in Cell A1 on in A1 to A20??
    Cheers!
    Deep Dave

  3. #3
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: Formula to remove 0's from part of a text string

    Hi NeedForExcel,

    It's all in cell A1.

    I think I've just achieved it by using this formula but all solutions are gratefully received.

    =IFERROR(SUBSTITUTE(MID(A1,1,LEN(A1)-1),0,"")&RIGHT(A1,1),"")

    Cheers,

    Snook

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,620

    Re: Formula to remove 0's from part of a text string

    Or to express it in other words:
    In one cell you have
    TS01
    in other
    TS03
    yet in another TS20

    or ...
    in one cell TS01 to TS20
    in other cell
    TS05 to TS15
    etc.

    Next question: is text part always 2 characters (TS, KA PE ER etc. or could be different length.

    It's very important especially if we plan to do this with as simple as possible formulas.

    To use full power of this forum - will you please attach a SMALL sample Excel workbook(s) (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. (If trere are typical cases like: all unique values/duplicates could occur, day/night, nobody present/several persons at once, before/on/past due, etc. - please show them all or at least indicate in text) The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution(s) is/are also shown (mock up the results manually).

    3. Make sure that all confidential/restricted information (either personal or business) like real e-mails, social security numbers, bank accounts, etc. is removed first!!

    To attach an Excel file you have to do the following: Just before posting, scroll down and press Go Advanced button and then scroll down and press Manage Attachments link. Now follow the instructions at the top of that pop-up screen.



    PS. from the answer posted while I was writiong above it seems that we are in case 1 - just single value

    But the "auto"solution does not care of such valies as
    TS101 - may be not your case, but you not disclosed that number part will be max 2 digit long
    Last edited by Kaper; 11-14-2017 at 05:05 AM.
    Best Regards,

    Kaper

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Formula to remove 0's from part of a text string

    Do the following
    Select the Range
    Ctrl+H >
    What what = TS0 >
    Replace with = TS >
    replace all >
    Close
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  6. #6
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: Formula to remove 0's from part of a text string

    Hi,

    I've uploaded the actual data I'm working with. I've spotted an error with my potential solution.

    Row 2 'AB10 to AB16' was converting to 'AB1 to AB16' which isn't what I require. This line should remain unchanged.

    Regards,

    Snook

  7. #7
    Registered User
    Join Date
    07-04-2017
    Location
    Belgium
    MS-Off Ver
    365 ProPlus
    Posts
    81

    Re: Formula to remove 0's from part of a text string

    Mmm, I can't open it?

  8. #8
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: Formula to remove 0's from part of a text string

    Hmmm, strange, does the attached work?

  9. #9
    Registered User
    Join Date
    07-04-2017
    Location
    Belgium
    MS-Off Ver
    365 ProPlus
    Posts
    81

    Re: Formula to remove 0's from part of a text string

    =IFERROR(LEFT(A1;FIND("0";A1)-1)&MID(A1;FIND("0";A1)+1;LEN(A1)-(FIND("0";A1)-1)); LEFT(A1; LEN(A1)))

    This might be a step in the right direction, but I'm encountering the TS20 -> TS2 problem as well.

    (A1 = cell with your value)

  10. #10
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Formula to remove 0's from part of a text string

    b2=SUBSTITUTE(A2,LEFT(A2,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A2&1/17))-1)&0,LEFT(A2,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A2&1/17))-1))
    Please Login or Register  to view this content.
    Try this and copy towards down

  11. #11
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,620

    Re: Formula to remove 0's from part of a text string

    My concept (if we stick to formulas):
    B2 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Valued Forum Contributor
    Join Date
    09-09-2009
    Location
    Liverpool, England
    MS-Off Ver
    W: 2021 H: 365
    Posts
    940

    Re: Formula to remove 0's from part of a text string

    Afternoon all,

    Once again this forum comes up trumps and digs me out of a hole!

    Thanks nflsales and Kaper, your assistance is much appreciated!

    Snook

+ 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] Lookup formula to find part of a text string
    By A440 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-30-2015, 08:21 AM
  2. [SOLVED] Can I remove the first part of a string of text and keep the second part?
    By Whoop92 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 02-12-2014, 07:44 PM
  3. Remove Part of String
    By Astrodude11 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-13-2012, 03:24 AM
  4. Replies: 13
    Last Post: 11-05-2011, 03:00 PM
  5. Remove Part of text string
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2008, 07:09 PM
  6. removing part text string with a formula
    By pertenax in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-07-2007, 07:08 AM
  7. [SOLVED] Use a formula to delete part of a text string?
    By Josh Craig in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-29-2006, 03:25 AM

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