+ Reply to Thread
Results 1 to 13 of 13

Using a nested IF Function and AND function on 2 sheets?

  1. #1
    Forum Contributor
    Join Date
    06-26-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    138

    Using a nested IF Function and AND function on 2 sheets?

    I am not sure if this is the correct type of formula so I'm looking for some help.

    I attached the workbook so you can see what I am working on.

    Basically what I am trying to do is as follows,

    If Sheet 1 Col B Matches Sheet 2 Col A (Unit Type) I want it to put in Sheet 1 Col F one of two things:

    IF Sheet 1 Col G (Market Rent) Matches Sheet 2 Col E for that Unit Type (Sheet 1 Col B or Sheet 2 Col A) then put Sheet 2 Col G
    IF it does not match for that unit type then I want it to Subtract the Sheet 2 Col E from Sheet 1 Col G (Market Rent) add that to Sheet 2 Col G and return that number in Sheet 1 Col F.

    Figuring out what I am talking about is probably harder that the actual formula so please let me know what clarification will help! I greatly appreciate any efforts on this!
    Attached Files Attached Files
    Last edited by heresteve2; 04-28-2014 at 05:25 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Using a nested IF Function and AND function on 2 sheets?

    =IF($G5=VLOOKUP($B5,Sheet2!$A$6:$E$10,5,0),Sheet1!$G5,Sheet1!$E5-VLOOKUP($B5,Sheet2!$A$6:$E$10,5,0)+Sheet1!$G5)

  3. #3
    Registered User
    Join Date
    03-19-2013
    Location
    Cambridge, England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Using a nested IF Function and AND function on 2 sheets?

    I'm not sure that gak has it completely correct. Vlookup is the correct function to use here to find the matching value in sheet 2, as gak has pointed out.

    If I'm following your logic correctly this is the formula I get:

    =IF($G5=VLOOKUP($B5,Sheet2!$A$6:$H$10,5), VLOOKUP($B5,Sheet2!$A$6:$H$10,7), $G5-VLOOKUP(B5,Sheet2!$A$6:$H$10,5)+VLOOKUP($B5,Sheet2!$A$6:$H$10,5))

    You said "Subtract the Sheet 2 Col E from Sheet 1 Col E (Market Rent)" but market rent is column G of sheet 1 so this is what my formula uses.

  4. #4
    Forum Contributor
    Join Date
    06-26-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    138

    Re: Using a nested IF Function and AND function on 2 sheets?

    Quote Originally Posted by Alex H View Post
    You said "Subtract the Sheet 2 Col E from Sheet 1 Col E (Market Rent)" but market rent is column G of sheet 1 so this is what my formula uses.
    Good Call Alex, it should have been Col G. That said your formula still isn't returning what I am looking for. It seems to return the market rent in most cases? For Example Row 8 Should return 704 but instead I'm getting 774?

    Thanks so much for taking the time to help here!

  5. #5
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Using a nested IF Function and AND function on 2 sheets?

    Yes, Alex is right, I got my Sheet1 and Sheet2 mixed up.

  6. #6
    Forum Contributor
    Join Date
    06-26-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    138

    Re: Using a nested IF Function and AND function on 2 sheets?

    Maybe it would help if I explained my example.

    Row 8 The market rent on Sheet 1 is 774 and the market rent on sheet 2 is 739 (both under unit type 1C10) Since they are different I take 774-739 and get 35. Add that to sheet 2 Col G (669) it should return 704.

    Does that help? Thanks!

  7. #7
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Using a nested IF Function and AND function on 2 sheets?

    In Alex H's formula change the last 5 to a 7 and you'll have what you want.

  8. #8
    Registered User
    Join Date
    03-19-2013
    Location
    Cambridge, England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Using a nested IF Function and AND function on 2 sheets?

    Haha, we got there in the end! Gak67 is correct, change the 5 for a 7. I'd just worked it out myself but you beat me to it.

    Final answer:

    =IF($G5=VLOOKUP($B5,Sheet2!$A$6:$H$10,5),VLOOKUP($B5,Sheet2!$A$6:$H$10,7),$G5-VLOOKUP($B5,Sheet2!$A$6:$H$10,5)+VLOOKUP($B5,Sheet2!$A$6:$H$10,7))
    Last edited by Alex H; 04-28-2014 at 05:49 PM.

  9. #9
    Forum Contributor
    Join Date
    06-26-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    138

    Re: Using a nested IF Function and AND function on 2 sheets?

    That did it!

    I promise to spend at least an hour tomorrow trying to understand the VLookUp Function, but I can thank you enough for saving me a ton of time!

  10. #10
    Registered User
    Join Date
    03-19-2013
    Location
    Cambridge, England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Using a nested IF Function and AND function on 2 sheets?

    No problem vlookup is a very powerful tool. Unfortunately because we have to lookup a few times in this example it's not that easy to understand if it's the first time you've come across it.

    Try to start by thinking about just one chunk: VLOOKUP($B5,Sheet2!$A$6:$H$10,5) looks for B5 in the first column of the range Sheet 2 A6:H10, and returns the value from the 5th column of that range.

  11. #11
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Using a nested IF Function and AND function on 2 sheets?

    I'd also put a ,0 or ,FALSE at the end of the function. If this is omitted it will find the next closest alternative rather than return an error if it can't find the value you're looking up. It can make you think it's working when it's giving the wrong info.

  12. #12
    Forum Contributor
    Join Date
    06-26-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    138

    Re: Using a nested IF Function and AND function on 2 sheets?

    Quote Originally Posted by Alex H View Post
    No problem vlookup is a very powerful tool. Unfortunately because we have to lookup a few times in this example it's not that easy to understand if it's the first time you've come across it.

    Try to start by thinking about just one chunk: VLOOKUP($B5,Sheet2!$A$6:$H$10,5) looks for B5 in the first column of the range Sheet 2 A6:H10, and returns the value from the 5th column of that range.
    I sort of get it, but where in the formula does it tell it to look in the first column of that range? Or does is always default to the first column? Also isn't it returning the value from the 6th column of the range? Why not make the range just A6 to A10? Thanks!

  13. #13
    Registered User
    Join Date
    03-19-2013
    Location
    Cambridge, England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Using a nested IF Function and AND function on 2 sheets?

    It always looks in the first column of your range (that doesn't need to be column A), it's a default for the VLookup function. No it's the 5th column for Market rent and 7th column for reduced rent.

    If you only selected 1 column (A6:A10) it would only be able to return the value you're looking up. That wouldn't be very useful as you already know it (unless you used it as a test).

    I suggest you look up VLookup in Excel help for a better explanation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Nested Function With Division - Receiving #VALUE! Function Error
    By DDM64 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-17-2013, 01:16 PM
  2. Replies: 6
    Last Post: 12-14-2012, 10:43 PM
  3. [SOLVED] Nested AND function within IF function is only addressing logical1 but not logical2
    By betic in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-20-2012, 09:17 AM
  4. Replies: 1
    Last Post: 04-16-2008, 08:45 AM
  5. Offset function with nested match function not finding host ss.
    By MKunert in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-21-2006, 06:50 PM

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