+ Reply to Thread
Results 1 to 18 of 18

LOOKUP within a IF statement

  1. #1
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    134

    LOOKUP within a IF statement

    I attached a spreadsheet for an example. I have a forumula
    =IF(COUNTIFS(Routing!$B:$B,$B4,Routing!$D:$D,K$2),"X","")
    The "X" is what will be returned if the statement is true, but I need to change that.
    I need it to look up a value that is on another sheet called "Routing" and return the value that is in column F.

    Thanks,
    Attached Files Attached Files
    Last edited by Coors; 05-06-2011 at 04:06 PM. Reason: solved

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

    Re: LOOKUP within a IF statement

    Use SUMIFS like you did the COUNTIFS just adding the sum range....

    In J4:

    =IF(COUNTIFS(Routing!$B:$B,$B4,Routing!$D:$D,J$2),SUMIFS(Routing!$F:$F,Routing!$B:$B,$B4, Routing!$D:$D,J$2),"")
    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 Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: LOOKUP within a IF statement

    It looks like you want it to look up and return multiple values, not "a" value. Is that true?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    134

    Re: LOOKUP within a IF statement

    Quote Originally Posted by ChemistB View Post
    It looks like you want it to look up and return multiple values, not "a" value. Is that true?
    Yes, as shown in the example. The TEST1 part number should have 1 under Lathe1, 2 under Lathe2, 3 under Lathe3, and 4 under Lathe5 in the Matrix tab.

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

    Re: LOOKUP within a IF statement

    I think that is what my formula does for you....

  6. #6
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    134

    Re: LOOKUP within a IF statement

    Quote Originally Posted by NBVC View Post
    Use SUMIFS like you did the COUNTIFS just adding the sum range....

    In J4:

    =IF(COUNTIFS(Routing!$B:$B,$B4,Routing!$D:$D,J$2),SUMIFS(Routing!$F:$F,Routing!$B:$B,$B4, Routing!$D:$D,J$2),"")

    I need the specific value in column F in the routing tab.
    For Example, cell AS with the sumif it is adding the 3 +7 to get 10, anyway to get "3,7" ????

  7. #7
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: LOOKUP within a IF statement

    THis formula in P7 dragged along, needs to be entered with Ctrl+Shift+Enter
    =INDEX(Routing!$F$2:$F$23,MATCH(P2&$B$7,Routing!$D$2:$D$23&Routing!$E$2:$E$23,0))
    Windows 7 using Office 2007 & 2010

    Remember your [ code ] [ /code ] tags, makes reading soooo much easier

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

    Re: LOOKUP within a IF statement

    Try adding this UDF to your VB Editor:

    Please Login or Register  to view this content.
    Then in J4 use formula:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER not just ENTER.


    P.s. I sure hope Microsoft improves the CONCAT function to allow for ranges... this would be much more useful...

  9. #9
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: LOOKUP within a IF statement

    slight adjustment to take account of #NA error,

    Please Login or Register  to view this content.
    Ctrl+Shift+Enter
    Last edited by scottylad2; 05-06-2011 at 03:50 PM.

  10. #10
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    134

    Re: LOOKUP within a IF statement

    Quote Originally Posted by NBVC View Post
    I think that is what my formula does for you....
    IF the part is routed to the same machine more than once the formula is adding it together.
    I need the specific value in column F in the routing tab.
    For Example, cell AS with the sumif it is adding the 3 +7 to get 10, anyway to get "3,7" ????

  11. #11
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: LOOKUP within a IF statement

    have a look and see if this is what you're looking for
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    134

    Re: LOOKUP within a IF statement

    Quote Originally Posted by NBVC View Post
    Try adding this UDF to your VB Editor:

    Please Login or Register  to view this content.
    Then in J4 use formula:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER not just ENTER.


    P.s. I sure hope Microsoft improves the CONCAT function to allow for ranges... this would be much more useful...
    OK, your way over my head, how do you "Try adding this UDF to your VB Editor:"

  13. #13
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    134

    Re: LOOKUP within a IF statement

    Quote Originally Posted by scottylad2 View Post
    have a look and see if this is what you're looking for
    Yes, it works and it returns the 1st value, the problem is sometimes the part is routed back to the same machine (see part N123) Seq Nbr 3 and Seq 7 are both CNC Grind4

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

    Re: LOOKUP within a IF statement

    While in the worksheet, hit ALT+F11, go to Insert and select Module, paste the first code.

    Then in the worksheet, in J4, enter the formula and confirm with CTRL+SHIFT+ENTER and then copy across and down

  15. #15
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    134

    Re: LOOKUP within a IF statement

    Quote Originally Posted by NBVC View Post
    While in the worksheet, hit ALT+F11, go to Insert and select Module, paste the first code.

    Then in the worksheet, in J4, enter the formula and confirm with CTRL+SHIFT+ENTER and then copy across and down
    I'm using Microsoft 2007, I do not see "Module"

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

    Re: LOOKUP within a IF statement

    When you get to the VB Editor by hitting ALT+F11, there should be and Insert menu at the top... click and select Module from that.. the editor will be clear and ready for you to paste the macro in....

    I attached your workbook with the macro and formula in place.
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    134

    Re: LOOKUP within a IF statement

    Quote Originally Posted by NBVC View Post
    When you get to the VB Editor by hitting ALT+F11, there should be and Insert menu at the top... click and select Module from that.. the editor will be clear and ready for you to paste the macro in....

    I attached your workbook with the macro and formula in place.
    I must of had a fat finger, I tried it again and it worked

  18. #18
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    134

    Re: LOOKUP within a IF statement

    Quote Originally Posted by NBVC View Post
    While in the worksheet, hit ALT+F11, go to Insert and select Module, paste the first code.

    Then in the worksheet, in J4, enter the formula and confirm with CTRL+SHIFT+ENTER and then copy across and down
    It works great!! Thanks the help. I really need to take a class on this stuff. It is amazing what you can do.

    Thanks again for your time.

+ 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