+ Reply to Thread
Results 1 to 4 of 4

Number Output

  1. #1
    Registered User
    Join Date
    10-25-2008
    Location
    Gig Harbor, WA
    Posts
    3

    Number Output

    So, I have many cells that contain a number and a word. Is the any function in Excel that will just output the number only. For example, in a cell that contains "100% Buy", I just want the 100% and not the Buy. Any ideas?

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Number Output

    I believe that you have two options here, depending on how your data is formatted. Suppose cell A1 contains the text "100% Buy".

    Option 1

    If the formatting is consistently such that you want everything before the space and nothing after it, then you could use the following simple formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This will find the location of the space in the text, and return everything before (not including) the space.

    Option 2

    If the number could be before or after the space (or even somewhere in the middle of the text), then it's a bit more complicated. However, this should do the trick:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This formula should be entered as an array formula, using Ctrl + Shift + Enter.

    To see what's happening here, I will break this formula down a bit for you. First, lets look at this part of the formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This part of the formula is breaking down the contents of cell A1 into a (virtual) array of text strings of length 1. Note that all characters in the resulting array are considered text, so the number 1 is actually considered the string "1". Multiplying by 1 at the beginning of this expression overcomes this.
    The next thing taking place in the formula is
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The ISNUMBER function returns "TRUE" if the parameter is a number, and "FALSE" otherwise (as you may have guessed). By placing this in a MATCH function, and attempting to match the value of "TRUE", the value that is returned will be the position of the first character in the text string in cell A1 that is a number.
    The second last thing to consider here is
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The COUNT function returns the number of single-character strings in the virtual array that contain numbers.
    Now by encompassing all of the above inside the MID function, what is returned is a substring of the original string in A1, starting at the position of the first number, and with a length equal to the number of numbers in the string.

    NB: This will only work if all of the numbers appear together. This will also not return the "%" sign that you requested.

    Some suggestions:
    1. If you want a "%" sign at the end of each of the numbers, then use the CONCATENATE function or the following formula (simpler):
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Note the only thing that has changed here is the '&"%"' at the end of the formula.

    2. If you have numbers scattered throughout the string in the target cell, then perhaps it's time to consider using VBA. Let me know if this is the case and I will help you out with a solution, but for now I have tried to keep the solution VBA-free, although it may seem a little bit messy.

  3. #3
    Forum Contributor
    Join Date
    06-26-2013
    Location
    LAX
    MS-Off Ver
    Excel 2007,Excel 2010
    Posts
    363

    Re: Number Output

    Hi Try this array formula. Should be confirmed with Ctrl+Shift+Enter.

    It extracts number and special characters, between the text.


    Please Login or Register  to view this content.
    Last edited by elayaz; 08-09-2013 at 06:40 AM.

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Number Output

    if it can be xxx yyyy 100% zzz wwww
    or 20% bbbb
    or ffff 100%
    then
    =TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",20)),MAX(FIND("%",SUBSTITUTE(A1," ",REPT(" ",20)))-10,1),11))
    Last edited by martindwilson; 08-09-2013 at 06:49 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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] Output number as a number, not text
    By Ocean Zhang in forum Excel General
    Replies: 2
    Last Post: 08-07-2013, 10:23 PM
  2. Output value from a column only when it is a number
    By dlorenzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2011, 01:24 PM
  3. Counter number output
    By Tommy in forum Excel General
    Replies: 2
    Last Post: 05-01-2009, 06:11 PM
  4. Replies: 7
    Last Post: 12-18-2008, 07:34 PM
  5. Number of spaces in Col.B, as output in col.A
    By wali in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-16-2008, 01:45 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