+ Reply to Thread
Results 1 to 13 of 13

Use a formula to separate numbers from text

  1. #1
    Registered User
    Join Date
    10-07-2012
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    7

    Use a formula to separate numbers from text

    I need help with a formula to separate my numbers from text in a cell. I have seen the following and can get it to work if a cell has BA123 in it:
    Use following functions to separate your text and numbers from a cell.

    To separate text - "=LEFT(A2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))-1)"
    To separate number - "=RIGHT(A2,LEN(A2)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))+1)"

    My data is backwards: example
    Given Data-----------------------Need formula to retrieve number--------------------Need formula to retrieve letters
    79---------------------------------------------79
    79A-------------------------------------------79----------------------------------------------------A
    234------------------------------------------234
    234A----------------------------------------234----------------------------------------------------A
    234B----------------------------------------234----------------------------------------------------B

    I tried substituting A,B,C etc for the numbers above, but the formula is not understood

    Thank you,
    Sharon

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Use a formula to separate numbers from text

    Is it always just a single letter (or no letter) on the end of the string?

    How about posting some more examples but leave out the ---- dashes.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    10-07-2012
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Use a formula to separate numbers from text

    Hi Tony, Thank you for your response. At this point it is a single letter, but I am not sure what they will do in the future, so I was looking for a solution that might eventually accommodate the need to add AA, etc. to the end.

    I added the dashes, just to separate the columns. The data is not complex. I am just provided with a code that is a number with no letter, or a number with one letter. For now, let's assume that those are the only 2 cases. If they begin to add multiple letters at the end of the code, I will deal with it at that time.

    The code provided is currently a text string. The result generated in column B must be numeric, the result generated in Column C is text.
    The same formula must be used in column B for all rows.
    The same formula must be used in column C for all rows.

    Here are some examples not much different from my post but may be clearer.

    Provided code in A1 is 69
    Need a formula in B1 to generate 69
    Need a formula in C1 to generate nothing

    Provided code in A2 is 69A
    Need a formula in B2 to generate 69
    Need a formula in C2 to generate A

    Provided code in A3 is 235
    Need a formula in B3 to generate 235
    Need a formula in C3 to generate nothing

    Provided code in A4 is 235B
    Need a formula in B4 to generate 235
    Need a formula in C4 to generate B

    This is basically it ... the codes provided are simple.

    Please let me know if you need any further information to help. Thank you so much.
    Sharon

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Use a formula to separate numbers from text

    I am just provided with a code that is a number with no letter, or a number with one letter. For now, let's assume that those are the only 2 cases. If they begin to add multiple letters at the end of the code, I will deal with it at that time.
    Try this...

    Data Range
    A
    B
    C
    1
    69
    69
    2
    69A
    69
    A
    3
    235
    235
    4
    235B
    235
    B
    5
    ------
    ------
    ------


    This formula entered in B1 and copied down:

    =IF(COUNT(-RIGHT(A1)),A1,--LEFT(A1,LEN(A1)-1))

    This formula entered in C1 and copied down:

    =IF(COUNT(-RIGHT(A1)),"",RIGHT(A1))
    Last edited by Tony Valko; 04-24-2015 at 11:03 PM.

  5. #5
    Registered User
    Join Date
    10-07-2012
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Use a formula to separate numbers from text

    Tony,
    This is great. I have 2 questions. I have been looking around, but have not been able to determine what - in front of RIGHT and -- in front of LEFT mean. Can you please help me understand the meaning of the dashes (negative signs)?

    I checked the result of column B with an ISNUMBER and although it came back true, it did not do a numeric sort. I had to add VALUE to the formula. Can you let me know if I did this properly as I, again, am not sure of the impact of the dashes:
    =IF(COUNT(-RIGHT(A6)),VALUE(A6),VALUE(--LEFT(A6,LEN(A6)-1)))

    Thank you so much for your help. I really appreciate it.
    Sharon

  6. #6
    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: Use a formula to separate numbers from text

    Try this one
    in B1 and copy down

    =LOOKUP(10^308,--LEFT(A1,{1,2,3,4,5,6,7,8,9,0}))

    in C1 and copy dodwn

    =SUBSTITUTE(A1,B1,"")

    Row\Col
    A
    B
    C
    1
    79
    79
    2
    79A
    79
    A
    3
    234
    234
    4
    234A
    234
    A
    5
    234B
    234
    B
    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

  7. #7
    Registered User
    Join Date
    10-07-2012
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Use a formula to separate numbers from text

    Tony,
    Thank you ... can you tell me what the "^" and the - and the "--" in your formulas please?
    I am in bed now, but I will try your last formula in the morninr.
    Thank you so very much. i will get back to you.
    Take care,
    Sharon

  8. #8
    Registered User
    Join Date
    10-07-2012
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Use a formula to separate numbers from text

    I'm sorry ... thank you, Alkey - yours was the first post i saw in another forum. Can you help me understand your first formula? My questions are with 10^308 and the "--" before LEFT. Does this formula need to be entered as an array?
    Thank you for your response.
    Sharon

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Use a formula to separate numbers from text

    See this for an explanation of the dashes:

    http://xldynamic.com/source/xld.SUMPRODUCT.html

    The specific subject is a bit different but the dashes are explained within the text.

    Using the VALUE function along with the "dashes" is redundant.

    --LEFT(A6,LEN(A6)-1)

    VALUE(--LEFT(A6,LEN(A6)-1))

    Both return the same result.

    The first version is more efficient (less steps to calculate = faster to calculate = more efficient).

  10. #10
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Use a formula to separate numbers from text

    Assuming that you have data in Cell A1
    B1=IF(COUNT(A1),A1,LEFT(A1,LEN(A1)-1))
    C1==IF(COUNT(A1),"",RIGHT(A1,1))

    or
    b1=LOOKUP(99^9,LEFT(A1,ROW($1:$10))+0,LEFT(A1,ROW($1:$10))+0)
    C1=SUBSTITUTE(A1,B1,"")
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  11. #11
    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: Use a formula to separate numbers from text

    Hi smr,

    The 10^308 (ten power of 308) is a one way to enter a very big number and when it's used in a single cell instead of an array it will match numeric looking characters in a string. The -- (double unary) is used to convert numeric looking characters into real numbers.


    Thank you for the feedback!

    Please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools -> Mark thread as Solved).

  12. #12
    Registered User
    Join Date
    10-07-2012
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Use a formula to separate numbers from text

    Thank you all so much for your solutions and for your explanations. I understand it now. I was able to use Tony's solution in a SharePoint List which works very well and Alkey's solution in an Excel spreadsheet as either SharePoint doesn't support some of the formulaic content or I made an error entering(:; I will try again soon. Alkey's solution also works perfectly in Excel.

    I so appreciate all of your timely and clear responses; they will all be used in my project.

    Thank you again and I will mark this as SOLVED.
    Sharon

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Use a formula to separate numbers from text

    You're welcome. We appreciate the feedback!

+ 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] Excel2010 IF Formula to return value based on a separate date and two separate text values
    By jakecutler in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-12-2015, 03:24 AM
  2. Need formula to separate numbers from letters on a text.
    By Zmith in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-11-2013, 12:31 PM
  3. Replies: 10
    Last Post: 03-08-2012, 12:31 PM
  4. how to separate numbers from the text
    By nsd3 in forum Excel General
    Replies: 2
    Last Post: 12-11-2010, 10:25 AM
  5. Formula to separate numbers from text
    By acbocage in forum Excel General
    Replies: 2
    Last Post: 01-20-2009, 10:27 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