+ Reply to Thread
Results 1 to 13 of 13

how to remove 5th character if its a zero

  1. #1
    Forum Contributor
    Join Date
    06-28-2013
    Location
    usa
    MS-Off Ver
    Excel 2013
    Posts
    192

    how to remove 5th character if its a zero

    I have a long list of accounts... example 0105010010 I need a formula that if the 5th character (left to right) is a zero, to remove it, if not zero then leave it alone. Can someone please help me?

    Thank you!

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: how to remove 5th character if its a zero

    Good afternoon eeps24

    Perhaps something like :
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    (Assumes your list starts at A1)

    HTH

    DominicB

  3. #3
    Forum Contributor
    Join Date
    06-28-2013
    Location
    usa
    MS-Off Ver
    Excel 2013
    Posts
    192

    Re: how to remove 5th character if its a zero

    The cell I want to work on begins on D2 and downward. I tried to use your code and replaced A1 with D2 but it did not work. Here is my scree shot.

    Capture.JPG

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: how to remove 5th character if its a zero

    It may be that the value in D2 is actually 105010010, but you have custom formatting that is adding the leading 0..
    What does this return
    =ISNUMBER(D2)
    ?

    Pictures usually aren't very helpfull because we can't then copy/paste it into our own sheets for troubleshooting.
    Can you post a sample book instead?
    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  5. #5
    Forum Contributor
    Join Date
    06-28-2013
    Location
    usa
    MS-Off Ver
    Excel 2013
    Posts
    192

    Re: how to remove 5th character if its a zero

    I am loading a comma delimited file and yes the file does contain 0105010010. I had to format the column as text in order to keep the leading zero other wise I was going to lose it. I think I uploaded a sample to my post or atleast tried.
    Attached Files Attached Files

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: how to remove 5th character if its a zero

    Dominic's formula works for me.

    The picture you posted in post #3..
    E2, is that actually what happened when you entered the formula, or were you just trying to show the formula that you entered?

    If that's what actually happened, then it means that E2 is formatted as TEXT
    Change the format of the cell with the formula to General (or anything other than text) and RE-ENTER the formula

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: how to remove 5th character if its a zero

    Maybe this one

    =IF(RIGHT(LEFT(D2,5))="0",REPLACE(D2,5,1,""),D2)
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  8. #8
    Forum Contributor
    Join Date
    06-28-2013
    Location
    usa
    MS-Off Ver
    Excel 2013
    Posts
    192

    Re: how to remove 5th character if its a zero

    it worked! (dominc's forumula) few questions...

    1. Yes E2 was formatted as text, when I changed it to general it worked. Why wouldnt it work as text? Forumuals cant be in text mode?
    2. Great formula, im glad it worked but I would love to understand the coding behind it. Can you please break it down for me exactly what that forumula is saying?

    THANK YOU!

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: how to remove 5th character if its a zero

    Quote Originally Posted by eeps24 View Post
    1. Yes E2 was formatted as text, when I changed it to general it worked. Why wouldnt it work as text? Forumuals cant be in text mode?
    It depends on the order of events...Which came first, the Chicken or the Egg.

    If the Cell is formatted as text FIRST, and THEN a formula is entered...
    Then Excel sees the formula as just a text string (because you told it to with cell formatting), and shows it exactly as it's typed.

    If the Cells if formatted other than text, then a formula entered, THEN format the cell as text, it's fine.
    But at this point, if you ever have to RE-Enter that formula (edit it for some reason), then it will be back to the state you had before in post #3.

    However, It's almost never necessary to format a cell with formula as Text.
    Because if the formula does return a true text string, then it will be as such regardless of the formatting of the cell.

    Hope that helps.

  10. #10
    Forum Contributor
    Join Date
    06-28-2013
    Location
    usa
    MS-Off Ver
    Excel 2013
    Posts
    192

    Re: how to remove 5th character if its a zero

    thank you but I was also wondering if you can break down this formula to me? Whats the MID for? and I see LEFT and RIGHT, what are those doing exactly?
    =IF(MID(A1,5,1)="0",LEFT(A1,4)&RIGHT(A1,5),A1)

  11. #11
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: how to remove 5th character if its a zero

    Hi eeps24
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    It asks a question - IF the MIDdle of string in A1, 5 places in, 1 character long = 0 then show the LEFT 4 characters of string A1, and (&) the RIGHT 5 characters of A1. This effectively rebuilds the account number, leaving out the zero.

    Otherwise, just show the contents of A1 as they are.

    HTH

    DominicB

  12. #12
    Forum Contributor
    Join Date
    06-28-2013
    Location
    usa
    MS-Off Ver
    Excel 2013
    Posts
    192

    Re: how to remove 5th character if its a zero

    sweet! thank you... and I would use BEG and END as well for different positions?

  13. #13
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: how to remove 5th character if its a zero

    Hi

    No - you'd use LEFT() and RIGHT(), thus :
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    HTH

    DominicB

+ 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] Formula to remove first two character is second character is a number.
    By herbie226 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-20-2013, 02:59 PM
  2. [SOLVED] Remove first character in a cell when the second character is blank
    By eastdallasguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-01-2013, 03:11 PM
  3. Replies: 3
    Last Post: 11-20-2012, 10:03 PM
  4. How to remove character's in a row
    By Mohsin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2006, 02:37 AM
  5. Remove character?
    By spinkung in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-30-2006, 11:34 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