+ Reply to Thread
Results 1 to 3 of 3

Extract Math Formula from text string

  1. #1
    Registered User
    Join Date
    07-01-2010
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    1

    Extract Math Formula from text string

    Okay I've run into a bit of a dead end.

    Here is my situation:

    Lets say A1 is:

    ABCD1 (1/2)

    the rest of my table has a bunch of these
    BEDAF5 (20/319)

    I need to get the (1/2) out and make it show 0.5.

    So far I have this:
    =(REPLACE(A1,1,(FIND("(",A1)-1),"="))

    Basically replacing everything before the (1/2) into an equal sign.

    My problem is that =(REPLACE(A1,1,(FIND("(",A1)-1),"="))
    gives me "=(1/2)" instead of 0.5

    I have a text string with a math equation in it.

    DAYS (135/365)
    MONTH (8/12)
    WEEK (12/55)
    etc etc

    the pretitles are different so I did a replace function to remove everything before the first "("

    but I end up with it saying "=(135/365)" instead of actually calculating it.

    how do i switch that text string to a math equation?
    this is what i have.
    =(REPLACE(A1,1,(FIND("(",A1)-1),"="))
    Last edited by pike; 07-01-2010 at 01:26 AM. Reason: dupe post

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Extract Math Formula from text string

    Getting XL to handle the text string as a formula generally necessitates use of Evaluate - this can be handled in a number of ways from old XLM calls via Names , 3rd Party Add-Ins (morefunc.xll) to your own User Defined Functions (VBA).

    The UDF is perhaps simplest to demonstrate, eg:

    Please Login or Register  to view this content.
    the above, stored in a Module in VBE in a Macro Enabled file, can then be used in a cell along the lines of:

    Please Login or Register  to view this content.
    If you want to handle these strings specifically then you could use a far more customised UDF, eg:

    Please Login or Register  to view this content.
    called from a cell along the lines of:

    Please Login or Register  to view this content.
    ie in the above you let the UDF strip out and subsequently process the value of interest.

  3. #3
    Registered User
    Join Date
    06-28-2010
    Location
    hyderabad
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Extract Math Formula from text string

    try this
    =REPLACE(A1,(FIND("(",A1))+1,FIND(")",A1)-FIND("(",A1)-1,ROUND(MID(A1,FIND("(",A1)+1,FIND("/",A1)-FIND("(",A1)-1)*1/MID(A1,FIND("/",A1)+1,FIND(")",A1)-FIND("/",A1)-1)*1,2))

+ 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