+ Reply to Thread
Results 1 to 8 of 8

IF/AND question

  1. #1
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63

    IF/AND question

    I am having trouble making a code for this to put into a macro I am working on...

    Starting on Row 3...IF there is a value in a column B cell AND there is a value in a column D cell (same row), THEN use the following formula in column F: "=B cell - D cell", OR leave blank if not true.

    I know this is an easy one but I can't figure it out!

    Thanks
    Last edited by Nickster64; 12-15-2008 at 04:21 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    This would be a formula for that for cells in Row 3

    =IF(AND(B3<>"",D3<>""),B3-D3,"")
    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
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63
    Thanks NBVC, this worked well but it gives me a blank if for example cell B4 = a blank, and cell D4 = 1000. In this case I would want my result in cell F4 to = -1000.

    I am going to take the final formula and apply it to my entire column F because over time my list is going to grow larger.

  4. #4
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63
    I also noticed that the formula would return a blank if cell B4 = 1000 and cell D4 = 0 instead of cell F4 = 1000.

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Well, you stated that BOTH B3 and D3 should not be blanks to perform the operation .
    If you want F4 to be -1000 replace AND with OR ( depending on your conditions)

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Then you want OR()

    =IF(OR(B3<>"",D3<>""),B3-D3,"")

  7. #7
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63
    Yes OR did the trick, thank you.

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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