+ Reply to Thread
Results 1 to 17 of 17

Delete Last Character if its an 'N'

  1. #1
    Registered User
    Join Date
    10-27-2006
    Posts
    29

    Question Delete Last Character if its an 'N'

    I have a column of data.

    Some end in 'N' some don't.

    For the ones that end in 'N' I would like to remove the 'N'.

    Find and replace wouldnt work as some of them have an 'N' at the start or in the middle.

    How can I removed the last charcter if it is an 'N'?

    Thanks.

  2. #2
    Valued Forum Contributor
    Join Date
    07-11-2004
    Posts
    851
    if your column of data is "A", for the entry in row 1 put this in another column and then copy down for thelengthof your data

    =IF(RIGHT(A1,1)="n",LEFT(A1,LEN(A1)-1),A1)

    Then copy/paste this new column (values) wherever you need it
    not a professional, just trying to assist.....

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,719
    Try

    =LEFT(A1,LEN(A1)-(RIGHT(A1)="N"))

    note this isn't case-sensitive, if you want to remove "N" but not "n" amend to

    =LEFT(A1,LEN(A1)-(EXACT(RIGHT(A1),"N")))

  4. #4
    Registered User
    Join Date
    08-16-2007
    Posts
    5

    another scenario

    I have a similar situation as above, except i need to replace any word ending in "S" with "v" for a column. How would you write the formula to replace rather than just delete?

  5. #5
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Try this,

    =LEFT(A1,LEN(A1)-(EXACT(RIGHT(A1),"S")))&IF(RIGHT(A1,1)="S","v","")
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  6. #6
    Registered User
    Join Date
    08-16-2007
    Posts
    5

    Brilliant

    oldchippy, you're a genius. thanks!

  7. #7
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Quote Originally Posted by bwoolery
    oldchippy, you're a genius. thanks!
    Glad to help - thanks for the feedback

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,719
    Another way....

    =LEFT(A1,LEN(A1)-1)&SUBSTITUTE(RIGHT(A1),"S","v")

  9. #9
    Registered User
    Join Date
    08-16-2007
    Posts
    5

    yet another scenario

    Thanks oldchippy and daddylonglegs for your responses. Here's another one I'm wrestling with:

    I have a database where characters were encoded with a '*' before a letter to indicate that that letter is capitalized. I need to search all cells that begin with '*' and then capitalize whatever letter comes after the *, finally to delete the *.

    I.e. *j --> J

  10. #10
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try

    =IF(LEFT(A1,1)="*",UPPER(MID(A1,2,1))&RIGHT(A1,LEN(A1)-2),A1)


    rylo

  11. #11
    Registered User
    Join Date
    08-16-2007
    Posts
    5

    #NAME? error

    Rylo,

    I get the #NAME? error when doing your suggestion. Here's the example of what I was looking for (I think you understand but I gave a poor example above).

    A B
    1 *dog Dog
    2 *cat Cat
    3 *bird Bird

    Thanks!

  12. #12
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Do you have the UPPER function available? If you put the formula
    =UPPER("p")
    in a cell, does it error? If so, then you will need to bring in the relevant addin.

    If that is OK, then can you put in
    Find and correct errors in formulas
    in the help bar, and work through the "calculate a nested formula ..." steps to see which part of the formula is giving the error.

    rylo

  13. #13
    Registered User
    Join Date
    08-16-2007
    Posts
    5

    It works

    Sorry, Rylo, your formula does work! There was a space in the formula which is what caused the error. Thanks for your suggestion!

  14. #14
    Registered User
    Join Date
    10-10-2013
    Location
    DC
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Delete Last Character if its an 'N'

    Hi,

    I have a column of alphanumeric data. Some cells end in a period (.) while others don't. I want to delete the periods that are at the end of the cells but not the periods that might be found throughout the rest of the cells. I can't seem to figure out the proper formula for doing so. Any help would be much appreciated. Thanks!

  15. #15
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Delete Last Character if its an 'N'

    jfrost88,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  16. #16
    Registered User
    Join Date
    08-16-2016
    Location
    USA
    MS-Off Ver
    OFFICE 2016
    Posts
    2

    Re: Delete Last Character if its an 'N'

    For a dynamic Excel spreadsheet I want to use for my at home analysis, Stock Option Ticker JNJ170120C00125000 needs to be converted into .JNJ170120C125

    In other words, delete certain zeros and add a period at the beginning.

    This probably could be done more efficiently, but I accomplished this by some formulas I found on the internet and adapted:

    =MIN(FIND({"000"},K15&"000")) returns position 16, then

    =REPLACE(K15,AV15,3,"") where AV15 is position 16 returns JNJ170120C00125 as AW15 then

    =MIN(FIND({"00"},AW15&"00")) returns position 11 as AX15 then

    =REPLACE(AW15,AX15,2,"") returns JNJ170120C125 as AY15 then

    =CONCATENATE(".",AY15) puts in the leading period and returns .JNJ170120C125 which is what I want.


    HOWEVER, there are other Option Symbols which need to be automatically converted slightly differently, ie:

    ETN170120C00067500 needs to be converted to .ETN170120C67.5

    and ETN170120C00065000 needs to be converted to .ETN170120C65


    My initial formulas shown above return .ETN170120C675 for the first one and .ETN170120C650 for the second one.


    I would like to substitute .5 for 5 at the end of the string for the first one, and delete the final 0 in the second string without altering the result correctly obtained for JNJ above. Any suggestions?

    JNJ and ETN are 3 characters, but some of the option symbols can have 4 characters or 1 or 2 characters, so we do have to find the position of what we want to change, which can move around. Also, there can be other 0 and 5 in the string, so it's important that the final changes only apply to the last character in the string after it has been truncated as accomplished by my formulas above.

    Finally, hopefully these formulas will work through all the permutations of Option Symbols, but that will become better known after I can correctly convert ETN.

    Quite possibly there is a more straightforward way than my formulas, plus more formulas I am kindly requesting. If so, please don't hesitate to correct or streamline my initial formulas. Otherwise, some additional formulas to add to mine to get the correct result for ETN while not altering JNJ result will be much appreciated. The goal is to be able to insert the unconverted option symbol and have the formulas return the converted option symbol dynamically.

    I'm not good at VBA programming but if there is something I can just copy and paste, this would be great as an alternative. I will need some help copying and pasting, and activating the VBA, as I haven't done that in a long time.

    Hopefully I have been clear in the explanations. Thanks very much in advance.

  17. #17
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,960

    Re: Delete Last Character if its an 'N'

    Global999,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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