+ Reply to Thread
Results 1 to 21 of 21

VLOOKUP return multiple results

  1. #1
    Registered User
    Join Date
    02-12-2022
    Location
    Seattle, Washington
    MS-Off Ver
    2016 Pro
    Posts
    7

    VLOOKUP return multiple results

    I have what is essentially an employee tracker, but I can't get the attendance Calendar in the first tab to pull more than one call off per day. I am not sure if VLOOKUP is not the right function, I tried INDEX/MATCH but kept running into the same problem. All of the Employee pages are Identical, with the only table that needs searching is the ATTENDANCE calendar. I am only running 1 small script, that updates the name of each sheet with the Employees name.

    The formula I am running is an array:

    {=VLOOKUP($H10,INDIRECT("'"&INDEX(Lookup_sheets,MATCH(1,--(COUNTIF(INDIRECT("'"&Lookup_sheets&"'!$B$4:$B$51"),$H10)>0),0))&"'!$B$4:$D$60"),{2,3}, FALSE)}
    But again I am only getting 1 employee per day to show up on the calendar.



    Any help would be super appreciated!
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: VLOOKUP return multiple results

    Welcome to the forum.

    I don't see where in your sample workbook (which, by the way, is far too big and busy to be a true sample) you have mocked up what you want to do. I see only empty tables.

    Show us (manually) what you want - add some annotation to your workbook and/or highlight relevant cells/ranges to make what is blindingly obvious to you clear to us. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: VLOOKUP return multiple results

    It is a painful and will become slow way of structuring your data. I think they way to go is to use power query to join all the sheets into one big table and then just return the values for they day when something has been entered. But what is the maximum number of entries for a day, do they all appear in one cell or a sperate cell for each person?

    currently you want name 1 tardy and name 4 call off appearing?

    I am not a power query expert!

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: VLOOKUP return multiple results

    This article describes a method of extracting data from multiple worksheets based on criteria

    https://excelxor.com/2014/10/16/coll...on-conditions/

    VLOOKUP will only return the first matching value it finds.

    Not sure Power Query will extract data in its current format. VBA is an alternative.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Registered User
    Join Date
    02-12-2022
    Location
    Seattle, Washington
    MS-Off Ver
    2016 Pro
    Posts
    7

    Re: VLOOKUP return multiple results

    Hi AliGW,

    Sorry I wasn't super clear! I attached 2 screenshots of where the info I need sorted is in the workbook. I have the Calendar set up right now with a Vlookup formula that can only pull the first result. The second screenshot is where I need the info pulled from across all the sheets.


    Sorry for the confusion, I wasn't sure how I was supposed to lay out what I needed.


    Hi davsth,

    I am not familiar with Powerquery. The Maximum is 4 people per day, I do need one row per name, because the 2nd column is the type of infraction (tardy, call off, missed punch)


    Hi JohnTopley,

    I am very unfamiliar with VBA, I attempted to Google using VBA, but I could not find a script that would do what I needed.
    Attached Images Attached Images

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: VLOOKUP return multiple results

    This is a relatively simple job for O365, but is a BIG bit problematic in earlier versions! I thought I had it sorted.... but I'm still stuck.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  7. #7
    Registered User
    Join Date
    02-12-2022
    Location
    Seattle, Washington
    MS-Off Ver
    2016 Pro
    Posts
    7

    Re: VLOOKUP return multiple results

    Hello all!

    I found a "working" solution to this. It isn't very clean and I would appreciate any feedback about making this less nightmare-ish. Because it is a nightmare of a formula.

    =IFERROR(INDEX(INDIRECT("'"&INDEX(Lookup_sheets,1)&"'!$A$13:$A$60"),MATCH(H10,INDIRECT("'"&INDEX(Lookup_sheets,1)&"'!$B$13:$B$60"),0)),"")&" "&IFERROR(INDEX(INDIRECT("'"&INDEX(Lookup_sheets,2)&"'!$A$13:$A$60"),MATCH(H10,INDIRECT("'"&INDEX(Lookup_sheets,2)&"'!$B$13:$B$60"),0)),"")&" "&IFERROR(INDEX(INDIRECT("'"&INDEX(Lookup_sheets,3)&"'!$A$13:$A$60"),MATCH(H10,INDIRECT("'"&INDEX(Lookup_sheets,3)&"'!$B$13:$B$60"),0)),"")&" "&IFERROR(INDEX(INDIRECT("'"&INDEX(Lookup_sheets,4)&"'!$A$13:$A$60"),MATCH(H10,INDIRECT("'"&INDEX(Lookup_sheets,4)&"'!$B$13:$B$60"),0)),"")&" "&IFERROR(INDEX(INDIRECT("'"&INDEX(Lookup_sheets,5)&"'!$A$13:$A$60"),MATCH(H10,INDIRECT("'"&INDEX(Lookup_sheets,5)&"'!$B$13:$B$60"),0)),"")&" "&IFERROR(INDEX(INDIRECT("'"&INDEX(Lookup_sheets,6)&"'!$A$13:$A$60"),MATCH(H10,INDIRECT("'"&INDEX(Lookup_sheets,6)&"'!$B$13:$B$60"),0)),"")&" "&IFERROR(INDEX(INDIRECT("'"&INDEX(Lookup_sheets,7)&"'!$A$13:$A$60"),MATCH(H10,INDIRECT("'"&INDEX(Lookup_sheets,7)&"'!$B$13:$B$60"),0)),"")&" "&IFERROR(INDEX(INDIRECT("'"&INDEX(Lookup_sheets,8)&"'!$A$13:$A$60"),MATCH(H10,INDIRECT("'"&INDEX(Lookup_sheets,8)&"'!$B$13:$B$60"),0)),"")&" "&IFERROR(INDEX(INDIRECT("'"&INDEX(Lookup_sheets,9)&"'!$A$13:$A$60"),MATCH(H10,INDIRECT("'"&INDEX(Lookup_sheets,9)&"'!$B$13:$B$60"),0)),"")&" "&IFERROR(INDEX(INDIRECT("'"&INDEX(Lookup_sheets,10)&"'!$A$13:$A$60"),MATCH(H10,INDIRECT("'"&INDEX(Lookup_sheets,10)&"'!$B$13:$B$60"),0)),"")

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: VLOOKUP return multiple results

    I've just had a breakthrough!! It has taken a couple of hours, off-and-on. I just now need to pull it all together. Should be done by beer o'clock Irish evening time (45 mins to you)

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: VLOOKUP return multiple results

    I've hit a snag or two.

    1. Below each date you have ONE cell. How are your proposing to get (potentially) several names and several infractions into one cell?

    2. Can I rearrange January appropriately to show a maximum of ?? 4 ?? infractions on any single day?

    3. Setting this up for 12 months will be a tad tedious I'll do it for one month... but NOT for all 12... Would you be prepared to consider an alternative structure? You display ONE month at a time, with the month selected via a dropdown box?

  10. #10
    Registered User
    Join Date
    02-12-2022
    Location
    Seattle, Washington
    MS-Off Ver
    2016 Pro
    Posts
    7

    Re: VLOOKUP return multiple results

    For the first day of Jan, I have 4 rows below the date, just for each person. I would be open to how the Calendar page is set up , but it does need to auto update the year when the "YEAR" box is filled in. If you can get the formula working for just the one day, I can format the rest of the page; because I wholeheartedly agree that the formatting is going to be a tedious task.

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: VLOOKUP return multiple results

    VBA

    In sheet "CALENDAR": right-click on Tab name and "View Code"

    Please Login or Register  to view this content.

    In the main "module"

    Please Login or Register  to view this content.

    Double_click on a date in "CALENDAR" to activate: currently data for 1st and 2nd January

    Output in AO8 table in CALENDAR
    Attached Files Attached Files

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: VLOOKUP return multiple results

    I have made it much easier to "do" a year. I will "do" January and then stop... I'm going cross-eyed.

    I do not propose to explain ANYTHING yet. You need to test it for JANUARY only. DO NOT try to copy it across the year ... yet.

    There is a "bug". You will need to ensure that BOTH a date AND a REASON are entered. I'm sure we can fix that with data validation a bit later.

    As you look at it... I have created 4 Named Ranges (sheets, date, name & offence). Sheets is different from Lookup_sheets.

    Will you me adding many more staff positions (i.e. sheets)?? I NEED to know.

    I changed C13 downwards in all your individual's sheets.



    That's me for now. You'd better like it....
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    02-12-2022
    Location
    Seattle, Washington
    MS-Off Ver
    2016 Pro
    Posts
    7

    Re: VLOOKUP return multiple results

    No, all staffing positions are accounted for with the Open sheets. Also Sir, those are fantastic and you are fantastic! Well done indeed, thank you!

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: VLOOKUP return multiple results

    Ummm. Who are you talking to? me with a formula or John, with VBA?

  15. #15
    Registered User
    Join Date
    02-12-2022
    Location
    Seattle, Washington
    MS-Off Ver
    2016 Pro
    Posts
    7

    Re: VLOOKUP return multiple results

    Both of you! Thank you John for your VBA code and Glenn for your Calendar! You two both rock.

  16. #16
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: VLOOKUP return multiple results

    So. Which way do you want to go? Formula or VBA??? There's no point in me going further with this if you intend to use VBA....

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: VLOOKUP return multiple results

    @Glenn: FYI

    The VBA solution does not update the Calendar directly; it puts the results into a table (AO8) which the OP had set up at one time.

    Using the layout you adopted for your formula solution i.e. 4 lines per date would be more amenable to the VBA approach but still a pain!

  18. #18
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: VLOOKUP return multiple results

    If you don't mind to use a lot of helper cells.

    1. Build builder sheet.

    enter all sheet name in column D and include column / row start / row stop of date field in each sheet
    (I think all are the same but provide just in case)

    count occurance of record
    H5
    =IF(D5<>0,IFERROR(COUNTIF(INDIRECT("'"&D5&"'!"&E5&F5&":"&E5&G5),">0"),0),0)

    setup starter of all per sheet
    J5
    =IF(D5>0,IF(MAX(J$4:J4)=0,IF(SUM(H$4:H5)>0,1,SUM(H$4:H4)),SUM(H$4:H4)+1),0)

    build ALL data area
    M5
    =IF(L5<=$J$2,IF(LOOKUP(L5,$J$4:$J$26,$D$4:$D$26)=0,M4,LOOKUP(L5,$J$4:$J$26,$D$4:$D$26)),"")

    N5 (in case sheet name is not the same to employee name)
    =IF($L5<=$J$2,INDIRECT("'"&$M5&"'!D2"),"")

    O5 (row of each record)
    =IF($L5<=$J$2,IF($M4<>$M5,MATCH($N5,INDIRECT("'"&$M5&"'!C:C"),0),MATCH($N5,INDIRECT("'"&$M5&"'!C"&O4+1&":C"&G5),0)+O4),0)

    P5
    =IF($L5<=$J$2,INDIRECT("'"&$M5&"'!B"&$O5),"")

    Q5
    =IF($L5<=$J$2,INDIRECT("'"&$M5&"'!D"&$O5),"")

    S5 (merge each date together)
    =IF($L5<=$J$2,IF(COUNTIF($P$4:$P5,$P5)=1,$N5&" "&$Q5,IFERROR(LOOKUP(2,1/($P$4:$P4=$P5),$S$4:$S4)&CHAR(10)&$N5&" "&$Q5,$N5&" "&$Q5)),"")
    Note : I've add char(10) [ line feed ] for new line in the output

    Then , back to CALENDAR sheet
    H11
    =IFERROR(LOOKUP(2,1/(Builder!$P$4:$P$221=H10),Builder!$S$4:$S$221),"")
    Note : output become one cell, so need to adjust row height and width

    Regards.
    Attached Files Attached Files

  19. #19
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: VLOOKUP return multiple results

    Please Login or Register  to view this content.
    Minor modification to go through all sheets and extract ALL the items and place in table in AO9. "RUN" button calls macro.

    My own view is that such a list is better than filling in your calendar which requires much scrolling to focus on any month.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    02-12-2022
    Location
    Seattle, Washington
    MS-Off Ver
    2016 Pro
    Posts
    7

    Re: VLOOKUP return multiple results

    Thank you everyone for all this help, ❤️. I worked with my supervisor for a few days trying out the different help you all provided.

    How do I mark a question as solved?

  21. #21
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: VLOOKUP return multiple results

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

+ 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. Return a summary of multiple vlookup results
    By JohnElliott in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-18-2019, 09:55 AM
  2. Help using vlookup to return multiple results for one vlookup value
    By Akmon in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-27-2015, 06:00 AM
  3. How VLOOKUP can return multiple results
    By BOB202 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-07-2013, 03:50 PM
  4. Vlookup (or something!) to return multiple results?
    By Madraykin in forum Excel General
    Replies: 3
    Last Post: 04-24-2012, 11:30 AM
  5. Vlookup to return multiple results?
    By cdotyii in forum Excel General
    Replies: 8
    Last Post: 09-05-2011, 10:23 AM
  6. Replies: 3
    Last Post: 01-24-2007, 05:38 AM
  7. [SOLVED] how to return multiple results in vlookup?
    By Landa in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-20-2006, 03:35 AM

Tags for this Thread

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