+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: Complex "IF" function

  1. #1
    Registered User
    Join Date
    07-07-2006
    Posts
    22

    Complex "IF" function

    Attached is a sample of the spreadsheet I'm working on. The column I'm trying to amend is column O (within the Vertical Spreads tab). I have most of the formula correct, but I can't get the last few conditions correct...essentially, what I'm trying to do is write a formula that performs the following (I'll just write the whole thing out in plain english but you can see the formula I have so far in the spreadsheet):

    If column G=0 and column H>0, or if column G>0 and column H=0, then multiply column D by -1.5, if both columns G and H are greater than 0, then multiply column D times 2 and then multiply by -1.5, if D=0, then do nothing

    Thanks for your help!
    - John
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    MSO2007 on WinXP/MSO2000 on Win7/winXP
    Posts
    2,180
    The formula in column O seem significantly different from your description, but you might try this one:
    =IF(OR(AND(G3=0,H3>0),AND(G3>0,H3=0)),D3*-1.5,IF(AND(G3>0,H3>0),D3*-3))
    ---
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    07-07-2006
    Posts
    22
    Thank you very much! How can I modify this formula so that it does not say, "FALSE" in column O when there is no value entered in column D?
    - John

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    MSO2007 on WinXP/MSO2000 on Win7/winXP
    Posts
    2,180


    This mod will show 0 instead of FALSE:
    =IF(OR(AND(G3=0,H3>0),AND(G3>0,H3=0)),D3*-1.5,IF(AND(G3>0,H3>0),D3*-3,0))

    ---
    Ben Van Johnson

  5. #5
    Registered User
    Join Date
    07-07-2006
    Posts
    22
    Thank you very much! I have one minor tweak I want to make to this function and I cannot figure it out. The additional "IF/AND" I need to add is (in plain english), IF column B is "BTC" and the amount in column J is equal to or less than .05, then do nothing. Because my spreadsheet has changed a little, I've reattached another sample. Thank you in advance!

    - John
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-07-2006
    Posts
    22
    All,
    Here is the formula I think is closest to the tweak I need to add in my most recent post:

    IF(AND(B2="STC",J2<0.06),J2*0))

    However, I either get a "too many functions for this formula" type of error or a general error in formula type of error.

    What am I missing? Thanks!

    - John

  7. #7
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057
    Try this formula in O2 copied down

    =OR(B2<>"BTC",J2>0.05)*D2*COUNTIF(G2:H2,">0")*-1.5

  8. #8
    Registered User
    Join Date
    07-07-2006
    Posts
    22
    Thank you! That worked! There is one other tweak that I want to make, but I'm going to rack my brains trying to figure it out before I make another post.
    I appreciate your help!
    - John

  9. #9
    Registered User
    Join Date
    07-07-2006
    Posts
    22
    OK...I can't figure it out. How can I take the formula that Daddylonglegs supplied me with and add the additional criteria: if column D is blank, then show nothing.

    This will prevent column O from being nothing but "$0.00" all the way down.

    Thank you in advance...I appreciate your help!

    - John

  10. #10
    Forum Guru EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264
    =OR(B2<>"BTC",J2>0.05)*D2*COUNTIF(G2:H2,">0")*-1.5
    Add

    =IF(D2="","",OR(B2<>"BTC",J2>0.05)*D2*COUNTIF(G2:H2,">0")*-1.5)
    Regards
    Ed
    _____________________________
    Always learning, but never enough!
    _____________________________

  11. #11
    Registered User
    Join Date
    07-07-2006
    Posts
    22
    I tried adding to the function as you suggested but now when there is no value in Column D, I get the #VALUE! error in column O where I am putting the new formula.
    Many thanks for your continued support! I will keep trying.
    - John

  12. #12
    Forum Guru EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264
    When I put the revised formula in col O it works fine in the sheet you posted.

    Can you post a revised copy of your sheet?

    Regards
    Ed
    _____________________________
    Always learning, but never enough!
    _____________________________

  13. #13
    Registered User
    Join Date
    07-07-2006
    Posts
    22
    EdMac,
    Thank you very much for your help. Rather than just insert the red portion of the function you had suggested (which is what I did before), I just copied and pasted the whole thing into my spreadsheet and it works as advertised. I don't know what I did wrong, but obviously I missed something.
    Thank you GREATLY for your assistance. This forum has been a tremendous help to me!
    Cheers.
    - John

  14. #14
    Forum Guru EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264
    Good to hear you got it working - thanks for the feedback.

    Regards
    Ed
    _____________________________
    Always learning, but never enough!
    _____________________________

  15. #15
    Registered User
    Join Date
    07-07-2006
    Posts
    22

    Problem with complex "IF" function

    I've been working at this for awhile taking cues from previous suggestions on this thread and I cannot work out the error. I've attached my spreadsheet for reference. The problem is with the "IF" function in column O. The formula is actually correct except for the "OR" contingent that states (B3<>"BTC",J3>0.05) -- I need to modify this by adding (in plain english): "and column H is blank" to it. I've tried but to no avail. I will post if I figure it out.
    Thank you in advance for your help!
    - John
    Attached Files Attached Files

+ 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.2.0