+ Reply to Thread
Results 1 to 6 of 6

Trimming alphanumeric column that is not standard lenght

Hybrid View

  1. #1
    Registered User
    Join Date
    12-20-2012
    Location
    houston
    MS-Off Ver
    Excel 2010
    Posts
    12

    Trimming alphanumeric column that is not standard lenght

    Hello All,

    I have a data set in a column. The data set is a combination of alphabet and numeric.
    1. Data always starts with MG followed by numbers and then may end with a letter. e.g MG1234, MG1234A, MG12345B
    2. Length of the string is not always the same. e.g MG1234, MG12345, MG1234A, MG12345B
    3. the Desired outcome is that for each one of these entries translates to remove the last alphabet and populate a column beside it. e.g MG1234=>MG1234, MG1234A=>MG1234, MG12345B=>MG12345.

    Raw data Desired outcome
    MG16828 MG16828
    MG1761 MG1761
    MG182303 MG182303
    MG9161C MG9161
    MG1234B MG1234
    MG13434A MG13434

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

    Re: Trimming alphanumeric column that is not standard lenght

    Assuming your data starts in cell A1, give this formula a try...

    =LEFT(A1,LEN(A1)-(RIGHT(A1)>"9"))

  3. #3
    Registered User
    Join Date
    12-20-2012
    Location
    houston
    MS-Off Ver
    Excel 2010
    Posts
    12
    Quote Originally Posted by Rick Rothstein View Post
    Assuming your data starts in cell A1, give this formula a try...

    =LEFT(A1,LEN(A1)-(RIGHT(A1)>"9"))
    Thank you Rick, this works great. How would we modify if the last character is not a alphabet but a symbol like an * eg MG12345*

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,769

    Re: Trimming alphanumeric column that is not standard lenght

    Please try

    =LEFT(A1,LEN(A1)-(OR(CODE(RIGHT(A1))<48,CODE(RIGHT(A1))>57))*1)
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

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

    Re: Trimming alphanumeric column that is not standard lenght

    Give this formula a try (it returns the empty text string "" for a blank cell rather that an Error code)...

    =LEFT(A1,LEN(A1)-(ABS(CODE(RIGHT(0&A1))-52.5)>4.5))
    Last edited by Rick Rothstein; 05-31-2022 at 06:23 PM.

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,175

    Re: Trimming alphanumeric column that is not standard lenght

    Or try:

    =LEFT(A1,LEN(A1)-ISERR(--RIGHT(A1)))

+ 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] Trimming non-alphanumeric characters instead of spaces (LTrim/RTrim)
    By Sophie.Durrant in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2015, 01:08 PM
  2. Filter column “A” by “item” and take lenght of description
    By aleanboy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2014, 12:28 PM
  3. [SOLVED] Remove numbers from alphanumeric string. No standard format to the string.
    By ricunger in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-20-2012, 01:43 PM
  4. Excel 2007 : column and row lenght and width pixel values
    By Martinfits in forum Excel General
    Replies: 1
    Last Post: 11-26-2010, 03:57 AM
  5. Autofilter by Alphanumeric and non-standard numbers
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-12-2010, 10:44 AM
  6. split one column into two, according to the lenght of member
    By wali in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-03-2008, 03:32 AM
  7. Trimming Alphanumeric String
    By sagacious2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-19-2006, 03:45 AM

Tags for this Thread

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