+ Reply to Thread
Results 1 to 3 of 3

Extracting numbers from a combined text & number string

  1. #1
    Forum Contributor
    Join Date
    02-12-2006
    Location
    London UK
    Posts
    109

    Extracting numbers from a combined text & number string

    I am stumped trying to identify a combination of functions for removing text characters from a combined text & number string.

    For example, I have string 199H and I want to remove the H and be left with the number 199 in number format for subsequent calculations.

    The numerical part of the strings are of variable length, and may or may not have a single text character to be removed from the right hand side.

    Any ideas??

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444
    Hi,

    If your string is in A1,

    =IF(AND(CODE(RIGHT(A1))>=64,CODE(RIGHT(A1))<=122),VALUE(LEFT(A1,LEN(A1)-1)),A1)

    will test to see if the right hand character is a letter, and if so, return only the numeric part as a value.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Contributor
    Join Date
    02-12-2006
    Location
    London UK
    Posts
    109

    Solved!

    Hi Dave
    Your suggestion is very elegant and works perfectly.
    Many thanks
    Astrikor

+ 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