+ Reply to Thread
Results 1 to 10 of 10

Using vlookup and if/then statements for multiple tables

Hybrid View

HP RodNuclear Using vlookup and if/then... 04-06-2011, 04:13 PM
Richard Buttrey Re: Using vlookup and if/then... 04-06-2011, 04:27 PM
MarvinP Re: Using vlookup and if/then... 04-06-2011, 04:30 PM
HP RodNuclear Re: Using vlookup and if/then... 04-06-2011, 04:38 PM
Richard Buttrey Re: Using vlookup and if/then... 04-06-2011, 04:53 PM
MarvinP Re: Using vlookup and if/then... 04-06-2011, 04:47 PM
HP RodNuclear Re: Using vlookup and if/then... 04-06-2011, 05:00 PM
Richard Buttrey Re: Using vlookup and if/then... 04-06-2011, 05:04 PM
HP RodNuclear Re: Using vlookup and if/then... 04-06-2011, 05:14 PM
HP RodNuclear Re: Using vlookup and if/then... 04-06-2011, 05:15 PM
  1. #1
    Registered User
    Join Date
    11-04-2010
    Location
    Illinois
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    86

    Using vlookup and if/then statements for multiple tables

    Here is my problem:

    In Column A, there are lists of elements. In Column B & C, there are values associated with each element and these two columns are two different categories (Category 1 and Category 2).

    On a second sheet, I have a random generated sheet that contains elements in Column A that may or may not be on the first sheet and they have values in Column B. I have tried to create a huge formula in Column C that will look at the value associated with the elements on the 2nd sheet, then it will refer to the first sheet and if that value equals or exceeds the values in Columns B or C, it will either give the user one of three choices: "Category 1", "Category 2", or "Not NTS".

    However, try as I might, I cannot get this formula to work right b/c my formula is not giving me the right answers based on my workbook example given. I also run into the problem that if the element in the second sheet cannot be found in the first sheet table, I get a "#N/A" and I would prefer it to say "Not NTS". I tried using the "ISNA" function, but it seems to be also screwing with my results...

    I created a post before this one about this but I don't think it was as clear and so I created a second post that hopefully is more clear with a workbook example.

    Hopefully someone can help me b/c I have been attempting to do this for almost 4 hours now...

    HP RodNuclear
    Attached Files Attached Files
    Last edited by HP RodNuclear; 04-06-2011 at 05:15 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Using vlookup and if/then statements for multiple tables

    Hi,

    One way. In C2

    =IF(B2>INDEX('10CFR20_App_E_NTS'!B:B,MATCH(A2,'10CFR20_App_E_NTS'!A:A,FALSE),1),"Cat1",IF(B2>INDEX('10CFR20_App_E_NTS'!C:C,MATCH(A2,'10CFR20_App_E_NTS'!A:A,FALSE),1),"Cat2","Not NTS"))
    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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

    Re: Using vlookup and if/then statements for multiple tables

    Hi HP RodNuclear,

    Strange problem. I think you can't have the name of a range the same as the worksheet. Either that or you have an invalid character in the named range or worksheet name.

    I changed the Name Range to ElementTable and did a VLookup and it worked fine.

    See if you have a naming problem.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    11-04-2010
    Location
    Illinois
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    86

    Re: Using vlookup and if/then statements for multiple tables

    Richard, your code worked perfectly except for one thing: if the element is NOT listed in the table, it gives me a "#N/A" and I'd prefer for it to say "Not NTS" as well, but other than that, it works wonderful. Thank you so much.

    Also, b/c I am not familiar with index/match, I wanted to see why the vlookup isn't working. So MarvinP, I tried changing the table I used to 'ElementTable', but it still isn't working right. What else am I doing wrong???
    Last edited by HP RodNuclear; 04-06-2011 at 04:48 PM.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Using vlookup and if/then statements for multiple tables

    Hi,

    Since you have Excel 2010 you could wrap the whole formula in an =IFERROR() function.
    i.e.

    =IFERROR(original_formula,"Not NTS")

    Regards

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

    Re: Using vlookup and if/then statements for multiple tables

    Look at http://www.exceltip.com/st/Index_For...rmula/700.html and
    and then http://office.microsoft.com/en-us/ex...001154902.aspx

    In general VLookup only works if you are looking at the column on the leftmost of your range.

  7. #7
    Registered User
    Join Date
    11-04-2010
    Location
    Illinois
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    86

    Re: Using vlookup and if/then statements for multiple tables

    I actually am not using Excel 2010, but 2003. I tried wrapping the whole formula in "ISNA" instead of "IFERROR" and I get "True" or "False" instead of "Not NTS" or "Category 1" or "Category 2." How can Excel 2003 to just tell me what I originally asked for i.e. "Cat 1", "Cat 2", or "Not NTS", instead of "True" or "False"?

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Using vlookup and if/then statements for multiple tables

    Hi,

    It's a bit messy but you need to wrap the formula as follows

    =IF(ISERROR(original_formula),"Not NTS",original_formula)

    Regards

  9. #9
    Registered User
    Join Date
    11-04-2010
    Location
    Illinois
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    86

    Re: Using vlookup and if/then statements for multiple tables

    Actually nevermind, I figured it out. I just added an if statement after the isna function, then I copied my original formula for the 'if false' part, and it works! Thanks guys!

  10. #10
    Registered User
    Join Date
    11-04-2010
    Location
    Illinois
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    86

    Re: Using vlookup and if/then statements for multiple tables

    and I see you were going to offer me the same solution...

+ 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