+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : Mid + Search Calculation Problems

  1. #1
    Registered User
    Join Date
    10-08-2011
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    3

    Mid + Search Calculation Problems

    So I wasn't really sure about what to title this thread, but here is my problem:


    Upon importing data from a website, I get a cell (C10) that looks like this:

    +4 (-107)


    I then use this function to isolate the number in parentheses

    =MID(C10,(SEARCH(" ",C10)+2),4)


    This is what I get; so far so good:

    -107


    The next cell uses the following function to yield what should be a number between 0 and 1. The IF function uses a different equation depending on whether the value calculated above (D3) is positive or negative and results in .5 if D3=0:

    =IF(D3>0,1/((D3/100)+1),IF(D3<0,ABS(D3/100)/(ABS(D3/100)+1),0.5))


    If I just plug -107 into the cell manually I get 0.516908213


    HOWEVER-- With the Mid and Search function instead I get this value: -14.28571429, however as explained above this is not the correct value.


    Can anyone please explain why this error is occurring and how to fix it; OR a better way to accomplish what I am after?



    Thanks in advance,

    Kevin

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Mid + Search Calculation Problems

    try changing the Mid formula to:

    =MID(C10,(SEARCH(" ",C10)+2),4)+0

    to coerce the extracted text string to an actual number.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  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: Mid + Search Calculation Problems

    Your first formula returns a text string; change it to

    =--MID(C10, SEARCH(" ", C10) + 2, 4)

    You can simplify the other formula to

    =IF(D3 > 0, 1 / (D3/100+1), IF(D3<0, 1 / (1-100/D3), 0.5))
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    10-08-2011
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Mid + Search Calculation Problems

    Awesome, all of these tips worked.

    I didn't think to turn the text into a number; Also good call on the simplification. It's been a long while since taking a math course.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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