+ Reply to Thread
Results 1 to 30 of 30

Nested If with Vlookup, based on a Yes/no selection

  1. #1
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Nested If with Vlookup, based on a Yes/no selection

    Hi, I have a workbook that contains several sheets. One is the "Master list" ("Membership List") from which I need to extract data to put in others. I've managed to work some vlookup functions that extract data for some sheets which work OK, but I'm struggling to write a formula to extract vlookup data based on the contents of a particular Yes / No column in the "Membership List".

    I've done a simple workbook attached (the original has far more columns, but they aren't relevant to this post) - what I need to do is to populate the contents of the "Dining List" with the names of those that are actually dining, ie, where the "Dining?" column has a "Yes".

    I'm OK with the vlookup bit, but can't seem to get the correct syntax for the "If G (2 - 11) "Yes", then populate the cells in the Dining list; If "No", ignore the row.

    I would also like to bring in the "IFERROR" statement as well but that's far too much for my abilities.

    Not sure what the result will look like in terms of rows in the Dining List, but I need the rows to be without blank rows, ie in this instance there will only be 6 rows in the sheet.

    I hope someone can help - it's probably a simple formula to an expert....
    Thanks in advance.
    Rgds
    Mike Waring

    Sorry, just noticed the stated versions of windows and Excel are out of date - I'm using W10, with Office 2021 Pro Plus
    Attached Files Attached Files
    Last edited by MikeWaring; 02-06-2023 at 03:13 PM. Reason: Incorrect Xl / windows version

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    edit - just re-read your edit

    so filter should work
    but you want non contiguous columns
    just need to look that up in my examples
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    =FILTER(FILTER('Membership List'!C2:H11,'Membership List'!G2:G11="yes"),{1,1,1,0,0,1})
    can also add SORT

    you should also update the profile to show the version of excel you are using

    not sure what the IFERROR is for
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,781

    Re: Nested If with Vlookup, based on a Yes/no selection

    Dining List

    C2=IFERROR(INDEX(INDEX('Membership List'!$C$2:$H$11,,MATCH('Dining List'!C$1,'Membership List'!$C$1:$H$1,0)),SMALL(IF('Membership List'!$G$2:$G$11='Dining List'!$B$2,IF(ISNUMBER(MATCH('Membership List'!$H$2:$H$11,'Membership List'!$L$2:$L$4,0)),ROW('Membership List'!$D$2:$D$11)-ROW('Membership List'!$D$2)+1)),ROWS('Dining List'!$B$1:B1))),"")

    control+shift+enter

    Copy accross and down
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Hi Wayne, thanks for your two replies.

    I know this is going to sound totally moronic, but which cells do I past the formulas in? I've tried a test run by pasting it in C2 and D2, but get a #VALUE! error in them.

    Rgds
    Mike

  6. #6
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    formula(s) - I only posted 1

    =FILTER(FILTER('Membership List'!C2:H11,'Membership List'!G2:G11="yes"),{1,1,1,0,0,1})

    and that goes into C2

    BUT nothing else in the other cells - but then i would expect a spill error

    Not sure why you are getting a value - unless its a different spreadsheet to example

    you said you are using office 2021 - which should have the FILTER function
    but i would expect a name error


    added an image
    Attached Images Attached Images
    Last edited by etaf; 02-07-2023 at 01:34 PM.

  7. #7
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Hi Wayne, I noticed a small error I made when transposing your formula, in that I typed the incorrect range for Column G, but when I corrected it in cell c2, I now get a #SPILL! error.....

    Clearly I'm doing something wrong but I've sat goggle eyed comparing my actual sheet with your test but can't see any errors in my transposition...

    FYI - the names and ranges in my tests sheet I published are not the same as my original worksheet

  8. #8
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    spill error - usually means the other cells are not clear
    so C2 to F20 ???? or more must be clear
    select that range or more and clear contents - so if you expect a result to go down as far as say row100 - that needs to be clear

    now JUST paste the formula into Cell C2 only

    its an array so all the other cells will show the values automatically
    you dont copy or paste to the other cells

  9. #9
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,781

    Re: Nested If with Vlookup, based on a Yes/no selection

    I don't understand how you can use functions
    of office 365 when you write office 2010 in the
    your profile and why you didn't reply to my post ?

  10. #10
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Hi Wayne, yes XL 2021 does have the FILTER function...

    I've just redone the ranges again and repasted the formula (in my actual DINING LIST sheet the first active cell is D5, but that shouldn't affect anything?) , but now I'm getting a #CALC! error........

  11. #11
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Hi Caracalla, I'm trying to work through the first expert's suggestion at the moment, but have seen your answer, so thanks for that.
    I've recently had a new PC with W10 and Office version 2021, but forgot to update my Profile with the new details, which I've now corrected...
    Rgds
    Mike

  12. #12
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    can you post the formula you are using
    perhaps the actual sheet - if no sensitive info

    Note
    i use 2 filter functions
    one with an array
    {1,1,1,0,0,1}
    which shows which columns to show
    that must match up with the range you are using

  13. #13
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Thanks Wayne, I'll start again with a blank sheet and see what happens, but yes the Dining list sheet was still populated......

  14. #14
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    you profile has not updated

    calc is an error in the formula results , criteria not matching - or range not matching

    https://support.microsoft.com/en-us/...your%20formula.

    #CALC! errors occur when Excel's calculation engine encounters a scenario it does not currently support. Here's how to address specific #CALC! errors:

    spill is not space to put the array , as cells not blank

    https://support.microsoft.com/en-us/...2-ef9cc9ad4023
    #SPILL errors are returned when a formula returns multiple results, and Excel cannot return the results to the grid. For more details on these error types, see the following help topics:
    Last edited by etaf; 02-07-2023 at 02:12 PM.

  15. #15
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Hi Wayne, - Hmm, now getting a #CALC! error....
    The actual sheet does contain actual names and other details, but I can delete the email addresses so the names won't mean anything to you.
    Or perhaps I could post the sheet privately to prevent the details being shown?

  16. #16
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    if you could just change the names/email and post -
    rules do not allow off forum assistance

  17. #17
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Title SURNAME FIRST Concatenated Dining? Payment Type

    Wayne, in my actual "Membership list", the columns are A to Q, but the relevant ones are D to I , as just above...

    There are a total of 64 rows, the list starting at row 3, but only rows 3 to 46 has any data in them at the moment (the others are for new members or visiting diners)

    So the active rows are D3:I46, and the "Dining?" column is I3:I46

    Not sure if it makes a difference (don't know why it should), but I use several Vlookup formulas on cells C3:N64, but they work fine....

  18. #18
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    d to i
    10 columns
    if you are retuning all 10 to the list
    A to Q is a lot more

    so if you choose the range
    =FILTER(FILTER('Membership List'!A2:Q11,'Membership List'!G2:G11="yes"),
    now this needs to show the columns to return based on A
    a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q
    this is only needed if you are not returning all the columns - lets say you just want A,B,C,F
    are 1 is placed to represent the column to return
    A,B,C,0,0,F,0,0,0,0,0,0,0,0,0,0,0
    {1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0})

    =FILTER(FILTER('Membership List'!A2:Q11,'Membership List'!G2:G11="yes"),{1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0})


    can you just post the formula and what columns are in the range and you want to show and what column the F is in



    the matrix of 1 and 0 - starts at whatever column your filter range starts

    as i write this - not sure i'm explaining very well

  19. #19
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Hi Wayne, you are explaining it well, I'm just not that Excel savvy to follow it....

    So do I understand that I have to include effectively the whole sheet range of data, even though the columns / rows that contain the data I need to lookup / return are D3 to I64 (6 columns / 61 rows)?

  20. #20
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    =FILTER(FILTER('Membership List'!C2:H11,'Membership List'!G2:G11="yes"),{1,1,1,0,0,1})

    Column C in the membership list is the first column you want to show
    and column H is the last column
    so
    =FILTER(FILTER('Membership List'!C2:H11
    now we need the criteria anc column G has the yes - so we add that column as a criteria
    =FILTER(FILTER('Membership List'!C2:H11,'Membership List'!G2:G11="yes")

    Now if that was ALL the columns to show then
    FILTER('Membership List'!C2:H11,'Membership List'!G2:G11="yes")
    would do that
    But you only want to show columns

    C, D, E & H

    so we add the extra FILTER and use the
    {1,1,1,0,0,1}
    matrix
    C,D,E,F,G,H
    but F & G has zero - so will not show in the array

    hence the result shows
    C,D,E,H columns in the result

    =FILTER(FILTER('Membership List'!C2:H11,'Membership List'!G2:G11="yes"),{1,1,1,0,0,1})

  21. #21
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Here's the formula I've put into D5 in the "Diners List" sheet (the first row / column that will contain the returned data)... (so as not to confuse you, as I've said before the sheet has 64 rows, allowing for expansion, but only rows 3 to 46 actually has any data in them at the moment).

    =FILTER(FILTER('Brethren Master List Feb 2023'!D3:I46,'Brethren Master List Feb 2023'!I3:I46="yes"),{1,1,1,0,0,1})

  22. #22
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    No sure if its having an effect, but Col E ("Surname") in the Membership list is sorted A-Z....

  23. #23
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    no

    here is a mock up of what i think you are saying
    Attached Files Attached Files

  24. #24
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Just sorted it...
    What an idiot - the last argument I had the wrong column - should have been H3:H46, whereas I had I3:I46....

    Thanks Wayne for all your help and sorry if I've wasted your time....

    Kindest regards
    Mike

  25. #25
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    no problem , you are welcome, and glad we got to the result

  26. #26
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Wayne, the solution you have provided has wetted my appetite, in that I would like to add further columns to the outputted list. I (think) I'm able to follow your excellent explanation of how the formula works, but there's a slight addition in that some of the cells in the "Membership List" may not have any value entered . For example, taking the column "Payment Type", I may not know immediately how the payment is being made so until that time the returned value is 0. Is there a modification to the formula to return a blank cell, until such time the actual detail are completed , at which point it will return the entered value.

    This is also the case in some extra columns, some of which will have cells with no values entered at all. Example, the diners have a choice of 8 wines at various prices. In the particular column for any given wine, I'll be entering the cost in the "Membership List". clearly, only one option will be chosen by a diner, and of course if the diner doesn't wish to take wine, all 8 cells along the row will be blank. If the return is going to be 0, the "Diners List" will have a whole load of 0's which will make the sheet difficult to read.

    So again, my question is, rather return a 0 for a cell that is blank, I would like it also to return a blank.

    Thanks in advance for your extra help..
    Rgds
    Mike

  27. #27
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    I found this in another forum a while back

    =FILTER(FILTER(IF(ISNUMBER('Brethren Master List Feb 2023'!D2:I64),'Brethren Master List Feb 2023'!D2:I64,'Brethren Master List Feb 2023'!D2:I64&""),'Brethren Master List Feb 2023'!$I$2:$I$64="yes"),{1,1,1,0,0,1})

    Also with 365 version , 2021 version there is LET() -
    =LET(f,FILTER(FILTER('Brethren Master List Feb 2023'!D2:I64,'Brethren Master List Feb 2023'!I2:I64="yes"),{1,1,1,0,0,1}),IF(f=0,"",f))

    Which i'm still working on

    f is a variable and is set to
    so this part
    LET(f,FILTER(FILTER('Brethren Master List Feb 2023'!D2:I64,'Brethren Master List Feb 2023'!I2:I64="yes"),{1,1,1,0,0,1})
    and then
    IF(f=0,"",f)
    which changes a zero to a blank
    Attached Files Attached Files

  28. #28
    Registered User
    Join Date
    11-23-2010
    Location
    Leicester, England
    MS-Off Ver
    Excel 2021 Pro Plus
    Posts
    87

    Re: Nested If with Vlookup, based on a Yes/no selection

    Hi Wayne, again thanks for your rapid response.
    The LET formula works a treat....I've added 9 more columns and it works perfectly for all of them.
    Thanks once again for your expert help.
    Kindest regards
    Mike

  29. #29
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    you are welcome

  30. #30
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,732

    Re: Nested If with Vlookup, based on a Yes/no selection

    i thought i would see what happens if there is actually a 0 in a cell
    so that would need to be brought across and NOT a blank

    the Let() still made it blank
    wheres as
    =FILTER(FILTER(IF(ISNUMBER('Brethren Master List Feb 2023'!D2:I64),'Brethren Master List Feb 2023'!D2:I64,'Brethren Master List Feb 2023'!D2:I64&""),'Brethren Master List Feb 2023'!$I$2:$I$64="yes"),{1,1,1,0,0,1})
    correctly identified "" and 0
    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)

Similar Threads

  1. VLOOKUP is not refreshing based on data validation selection
    By warrior2411 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-12-2021, 12:32 AM
  2. [SOLVED] Nested vlookup or nested IFAND function?
    By jeptik in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-11-2017, 02:27 AM
  3. [SOLVED] vlookup value in a combobox2 based on the combobox1 selection
    By camt123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2016, 11:57 AM
  4. Nested Or IF based VLOOKUP
    By ekatecohn in forum Excel General
    Replies: 3
    Last Post: 01-26-2015, 05:59 PM
  5. Replies: 2
    Last Post: 08-13-2013, 09:36 AM
  6. vLookUp based on dropdown selection
    By michaelof36 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-20-2012, 08:30 PM
  7. Automate vlookup to create New worksheets based on selection criteria
    By kolokor in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2009, 08:13 AM

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