+ Reply to Thread
Results 1 to 7 of 7

Remove last character of a string if it's A-Z

  1. #1
    Registered User
    Join Date
    05-25-2021
    Location
    Michigan, US
    MS-Off Ver
    MS 365
    Posts
    37

    Remove last character of a string if it's A-Z

    Is it possible to search a column, and remove the last character(s) if they are not numerical?

    For example:

    if column A had values R065O, Sub10, Sub11, Sub12,Sub13,Sub14,Sub15,Sub16,Sub17,Sub18,Sub19,Sub1C,Sub20,Sub21,Sub23,Sub24,Sub25,Sub2C
    would like to return: R065, Sub10, Sub11, Sub12, Sub13, Sub14, Sub15, Sub16, Sub17, Sub18, Sub19, Sub1, Sub20, Sub21, Sub23, Sub24, Sub25, Sub2


    I would like to remove the letters from the END of the contents. I do not want to remove anything to the LEFT of the numbers, only the RIGHT.

    Thanks in advance!

    Sample book attached.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    11-02-2016
    Location
    NY
    MS-Off Ver
    2010
    Posts
    459

    Re: Remove last character of a string if it's A-Z

    if your data is in column A, copy the following formula (if not adjust ALL occurances of cell A1 to your cell)
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Remove last character of a string if it's A-Z

    In B2, enter =IF(ISNUMBER(INT(RIGHT(A2,1))), A2,LEFT(A2, LEN(A2)-1)) then autofill the formula.

  4. #4
    Registered User
    Join Date
    05-25-2021
    Location
    Michigan, US
    MS-Off Ver
    MS 365
    Posts
    37

    Re: Remove last character of a string if it's A-Z

    I understand I can accomplish with that formula.. but I really need it to be embedded in my VBA code and execute after I create the sorted sheet.
    I'm hoping to automate this.. IE loop through columns A,E,I,M, and Q respectively.. and trim any letters off the end of the numbers.

    I am trying to Eliminate anything after the number designation so I can create relationships in my report software utilizing the tag values.

    Essentially I am taking a complete value , inserting a row & breaking out the first 6 characters using =LEFT... then I want to loop through the created columns and remove any letters after the numerical portion of the tag.

    See attached samplebook...
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Remove last character of a string if it's A-Z

    VBA
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-25-2021
    Location
    Michigan, US
    MS-Off Ver
    MS 365
    Posts
    37

    Re: Remove last character of a string if it's A-Z

    This is perfect.

    all other solutions appreciated and rep given but this one is definitely the approach I'm using! Thanks!!!

  7. #7
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Remove last character of a string if it's A-Z

    Just noting that if you put this array-entered** formula in cell I2 instead of the one you have there now and copy it down, you would not need to do what you asked for in this question as the entry would be correct directly from the formula...

    =LEFT(J2,MAX(IF(ISNUMBER(0+MID(J2,ROW(I$1:I$99),1)),ROW(I$1:I$99))))

    **Commit this formula using CTRL+SHIFT+ENTER and not Enter by itself

+ 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. Remove - from a character string and consolidate
    By Rob Klyver in forum Excel General
    Replies: 5
    Last Post: 01-23-2015, 01:54 PM
  2. [SOLVED] Remove last character of string does not work
    By vonrainer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-10-2014, 04:10 AM
  3. [SOLVED] Remove last character from string and sum product
    By ABSTRAKTUS in forum Excel General
    Replies: 3
    Last Post: 04-03-2012, 10:46 AM
  4. Remove last word/character from a string
    By Delkath in forum Excel General
    Replies: 3
    Last Post: 09-08-2010, 01:48 PM
  5. Remove Last Character from String
    By SLP in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-03-2007, 05:17 PM
  6. remove special character at end of string
    By captain bob in forum Excel General
    Replies: 0
    Last Post: 08-03-2006, 09:59 AM
  7. Remove last character of text string
    By Grant in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-29-2005, 01:05 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