+ Reply to Thread
Results 1 to 13 of 13

Excel 2007 : Help needed to write a subtraction formula

  1. #1
    fxtrader
    Guest

    Help needed to write a subtraction formula

    I'm trying to write a formula that will deduct one number from another with varying decimal places to achieve a positive number result. e.g.

    1.32650 - 1.32750 = 10
    or
    1.32750 - 1.32650 = 10

    and

    75.250 - 75.150 = 10
    or
    75.150 - 75.250 = 10

    The answers shown above are what I need to achieve.

    Attached is what I have so far, however I have to adjust the formula each time depending on whether I'm subtracting three or five decimal places.

    This has plagued me for weeks, any assistance would be greatly appreciated.

    Thanks in advance, FXtrader
    Attached Files Attached Files

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Help needed to write a subtraction formula

    Hello,

    there may be a more elegant way, but try this in C1

    =ABS(A1-B1)*("1"&REPT("0",LEN(TEXT(ABS(A1-B1),"general"))-1))

    copy to C5 and see if it suits.

    cheers,

  3. #3
    fxtrader
    Guest

    Re: Help needed to write a subtraction formula

    Hello & thanks for your time, I thought you'd solved it but when I tried throwing a few random numbers in such as the following entries I didn't get the desired result;

    1.03446 - 1.03542 = 960 (the answer I need in this instance is 9.6)

    What are your thoughts?

    Thanks again
    Last edited by teylyn; 09-13-2011 at 06:27 AM. Reason: removed quote

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Help needed to write a subtraction formula

    Hi fxtrader,

    Try this formula in C1
    Please Login or Register  to view this content.
    It seems to me you are trying to get numbers between 1 and 10.

    Hope that is what you're looking for.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    fxtrader
    Guest

    Re: Help needed to write a subtraction formula

    Thanks again!

    The anwer will not always be betwee 1 - 10. The numbers I'm using in the calculation are currency prices and I'm trying to calculate the difference between the two in "pips". Pips are the unit of measure in currency trading. e.g. 125.145 - 120.00 = 514.5 pips

    Any suggestions?
    Last edited by teylyn; 09-13-2011 at 06:27 AM. Reason: removed quote

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Help needed to write a subtraction formula

    I guess I need some more examples.
    It seems Absolute Value of the difference times 100 should work in your last example.

    On http://www.informedtrades.com/22740-...onal-pips.html
    the explaination given is based on how many digits are displayed. Is that correct?
    Last edited by MarvinP; 09-13-2011 at 01:00 AM.

  7. #7
    fxtrader
    Guest

    Re: Help needed to write a subtraction formula

    Hi Marvin, some examples would be;

    1.32650 - 1.32850 = 20
    1.03445 - 1.03802 = 35.7
    124.550 - 121.000 = 355
    124.550 - 124.700 = 15
    79.839 - 80.00 = 16.1
    1.58556 - 1.56406 = 215

    Thanks for your time
    Last edited by teylyn; 09-13-2011 at 06:26 AM. Reason: removed quote

  8. #8
    fxtrader
    Guest

    Re: Help needed to write a subtraction formula

    The explanation on the link is correct.
    Last edited by teylyn; 09-13-2011 at 06:26 AM. Reason: removed quote

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Help needed to write a subtraction formula

    Hi,

    It looks like a PIP is dependent on how many decimals are given in the problem. Excel looks at numbers like your 121.000 from above and makes it 121. This makes the problem hard for programs that use numbers. I believe to do this problem you will need to pass a text string to the function and see how many letters/digits are to the right of the decimal to see what the base value of the PIP is. See the link I attached two posts above.

  10. #10
    fxtrader
    Guest

    Re: Help needed to write a subtraction formula

    Thanks for your assistance Marvin, I'm a bit too green with excel to understand what you mean however I appreciate your time. I can make the formula work but it seems that I need to manually change it depending on how many decimal places I use. I'm trying to find a way to avoid this. Please forgive my ignorance.
    Last edited by teylyn; 09-13-2011 at 06:26 AM. Reason: removed quote

  11. #11
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Help needed to write a subtraction formula

    fxtrader, please stop quoting whole posts. It's unnecessary clutter, makes the thread harder to read and creates work for the moderators.

  12. #12
    fxtrader
    Guest

    Re: Help needed to write a subtraction formula

    Well.. I apologize for not being a pencil neck thread freak like you Teylyn, jam your help

  13. #13
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Help needed to write a subtraction formula

    There goes your opportunity to get free help on this forum.

+ 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