+ Reply to Thread
Results 1 to 13 of 13

Formula to remove text char and convert remaining number based on meaning of text char

  1. #1
    Registered User
    Join Date
    02-25-2014
    Location
    Burnaby, BC
    MS-Off Ver
    Excel 2010
    Posts
    29

    Formula to remove text char and convert remaining number based on meaning of text char

    I have a simple list of numbers signifying terabytes (T), gigabytes (G), megabytes (M) or kilobytes (K) of data. The fields contain both a number with a text character, no space between them. I need to remove the text character and convert the remaining number to terabytes. So "900G" becomes ".900", "500M" becomes ".0005" etc. I've attached the example. Any help with this would be greatly appreciated.

    Thanks!
    Attached Files Attached Files
    Last edited by PWM; 04-08-2014 at 08:07 PM.

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    Is there only 6 possible characters to deal with? If so a nested if would work.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    Select the column,

    Find and replace T with E+0 (or nothing)

    Find and replace G with E-3

    Find and replace M with E-6

    ...

    Or, if you want a formula, in B3 and copy down,

    =LOOKUP(9E+307, --SUBSTITUTE(A3, {"T","G","M","K"}, "E-" & {0,3,6,9}))
    Last edited by shg; 04-09-2014 at 10:57 AM. Reason: Corrected cell reference
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    02-25-2014
    Location
    Burnaby, BC
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    Thanks. I should have clarified that I'm working with a very large list, which is updating daily so I need to be able to automatically achieve the result via a formula. Doing it manually with Find isn't feasible for me.

  5. #5
    Registered User
    Join Date
    02-25-2014
    Location
    Burnaby, BC
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    Sorry, I see that you did include a formula. My oversight. I'll give it a try!

    Thank you!

  6. #6
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    Can you walk through what that formula does shg?

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    Sure.

    It does the same thing the Find & Replace does, attempting all four substitutions. Only one of the four will work, and that's the one that the double-negation can convert to a number. The LOOKUP function always matches the lookup value with an array value of like type (here, a number), so it returns the value that works.

  8. #8
    Registered User
    Join Date
    02-25-2014
    Location
    Burnaby, BC
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    I've tried the formula but it returns "0.000000000". I don't understand it, so perhaps I'm using it incorrectly.

    What I think I need is a formula in column B that looks in column A and if it sees a "G" it removes the G and divides the remaining number by 1000 returning the result in column B. If it finds a "T" it removes it and does nothing further, if it finds an "M" it removes it and divides number by 1,000,000, and if it finds a "K" it removes it and divides by 1,000,000,000.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    A
    B
    C
    2
    Usage
    TB
    3
    994.0G
    0.994000000000
    B3: =LOOKUP(9E+307, --SUBSTITUTE(A3, {"T","G","M","K"}, "E-" & {0,3,6,9}))
    4
    12.3G
    0.012300000000
    5
    154.9M
    0.000154900000
    6
    64.5K
    0.000000064500
    7
    46.1T
    46.100000000000
    8
    4.2T
    4.200000000000


    Sorry, the B3 in the formula should have been A3.

  10. #10
    Registered User
    Join Date
    02-25-2014
    Location
    Burnaby, BC
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    Works great! Thank you. I'm a newbie, so the formula is quite foreign to me. What are some research topics that would help me understand it? The "9E+307" for example. But again, many thanks!

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    9E307 is close to the largest number Excel allows you to enter via the user interface (9.99999999999999E307). It just causes the LOOKUP function to return the largest (and only) number in the list.

  12. #12
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    9E+307 is the same as 9*(10^307) which is just a REALLY big number.


    redundant post! lol

    shg is on point here....

  13. #13
    Registered User
    Join Date
    02-25-2014
    Location
    Burnaby, BC
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Formula to remove text char and convert remaining number based on meaning of text char

    So scientific notation. Why do we want the LOOKUP to return the largest (and only) number in the list? What list? Sorry - as I said I'm a newbie.

+ 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] Function to take text from x:th char to next n char
    By Temporary-Failure in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-07-2013, 02:19 AM
  2. [SOLVED] Edit Text String Based on 3rd Occurrence of Char
    By Camel in forum Excel General
    Replies: 4
    Last Post: 07-19-2012, 10:06 AM
  3. Replies: 1
    Last Post: 04-05-2010, 02:08 AM
  4. Replies: 6
    Last Post: 03-10-2006, 01:15 PM
  5. [SOLVED] Create a formula to remove text to the left of specified char?
    By TheLazer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-18-2005, 07:06 AM

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