+ Reply to Thread
Results 1 to 11 of 11

Cross-reference 3 lists to return all available employees

  1. #1
    Registered User
    Join Date
    04-27-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    12

    Cross-reference 3 lists to return all available employees

    Hello, I am a super noob to vba but I have learned quite a lot on this board.
    I have three lists, one with a list of every state and all employees that are available to work in each state (ranges from 3 to 12 employees in each state), then another list with different limits (dollar amount) of authority that each employee has, the third list is a schedule of who is working on each day of the month. What I'm looking to do is write vba that would, based on the state that is input into a cell and todays date, look at the first list to see which employees are available in that particular state, then look the the second list to see which employee has the particular authority to do the work (dollar amount), then look at the schedule to see who is available that meets the first two criteria. Right now we are just using IF statements that refer to 5 different tables to determine who can work in each state, the rest of the information we are just looking up manually. Thanks in advance.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Cross-reference 3 lists to return all available employees

    Hi and welcome to the forum

    I understand that a lot of your data is probably sensitive, but it would help if you could provide a (cleaned) sample of the data you are working with, a few examples of your expected outcome, and how you arrived at them.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    04-27-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Cross-reference 3 lists to return all available employees

    Thanks FDibbins,
    Here's a quick example of what I would like. It's not the workbook I am currently using, that would take some time to clean up. Basically, we would be pasting information on the "Input" sheet in columns A and B. I would like the code to look at the "Table" sheet to see based on the amount, today's date, and the state who would be available to work and list them in column Don the first sheet. I could combine some of the information (authority and schedule) if needed.
    Attached Files Attached Files

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Cross-reference 3 lists to return all available employees

    You know you have...
    Eric AL
    Eric TX
    Kevin AL
    Kevin GA
    ?

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Cross-reference 3 lists to return all available employees

    the attached is a bit messy but it gives you what you want
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-27-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Cross-reference 3 lists to return all available employees

    I know. That's where it gets complicated. Some people can do work in many states.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Cross-reference 3 lists to return all available employees

    If you have people working in multiple states, assuming their availability will be the same, add extra state columns after D, andthen adjust this accordingly...
    =IF(AND($B4>=Input!$A$3,OR($C4=Input!$B$3,$D4=Input!$B$3),INDEX($E4:$K4,1,MATCH(TODAY(),$E$3:$K$3,0))<>"Off")=TRUE,MAX(L$3:L3)+1,MAX(L$3:L3))

  8. #8
    Registered User
    Join Date
    04-27-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Cross-reference 3 lists to return all available employees

    I think I may need to re-arrange my starting information. Maybe put the states first, then the employees for each state, then the authority amount then the schedule so it weeds them out as it goes down the line. What I would ultimately like is to just paste in a list of amounts and states (about 30 or so a day) on the "Input" tab and run a macro or have formulas nested that would return a list of available employees in column D on that same tab. So it would just look through all of the info on the "Table" sheet and return the answers on "Input".
    Attached Files Attached Files

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Cross-reference 3 lists to return all available employees

    Did you see my file in post #5?

    It makes things a lot easier if you have 1 table, including everything in it, like I had in my file

  10. #10
    Registered User
    Join Date
    04-27-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Cross-reference 3 lists to return all available employees

    Yes, I saw it. I'm still trying to wrap my head around it. I see how you put everything together on the table, I don't understand the amount columns (L-P). Do they just return the available employees at the bottom of the columns then you have to paste them onto the Input tab? I really appreciate the help. Like I said, I'm still learning so I have to go real slow through all of the formulas and figure out what they are pointing to. I'll try to apply this to the full workbook and see how it goes. Thank you.

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Cross-reference 3 lists to return all available employees

    What L-P do, is test to see if the 3 criteria are met -
    amount (B) greater than what is shown on Input...B4>=Input!$A$3
    State = state on Input...OR(C4=Input!$B$3,D4=Input!$B$3) We have states in 2 columns, this is the part you will have to extend if you add more than 2 states
    today's date <> off...INDEX($E4:$K4,1,MATCH(TODAY()-1,$E$3:$K$3,0))<>"Off") This is pretty much a fancy lookup formula
    If all conditions are met, it increases the counter by 1, else it just repeats the counter
    =IF(...all 3 conditions are met...,MAX($L$3:L3)+1,MAX($L$3:L3)) max() is the counter, so either increase by 1 (if TRUE) or just repeat counter
    =IF(AND(B4>=Input!$A$3,OR(C4=Input!$B$3,D4=Input!$B$3),INDEX($E4:$K4,1,MATCH(TODAY()-1,$E$3:$K$3,0))<>"Off")=TRUE,MAX($L$3:L3)+1,MAX($L$3:L3))

    At the bottom of that, I am extracting the name that corresponds to the 1st instance of a counter increase
    =IF(ISERROR(INDEX($A$4:$A$33,MATCH(ROW(A1),L$4:L$33,0),1)),"",INDEX($A$4:$A$33,MATCH(ROW(A1),L$4:L$33,0),1)) the if(iserror(blah blah part is for error trapping, the bolded is doing the work

    then finally, I am brute-forcing a concatenate of each of 11 possible names in rows 34:44...
    =Table!L34&IF(Table!L35="","",", "&Table!L35)&IF(Table!L36="","",", "&Table!L36)&IF(Table!L37="","",", "&Table!L37)&.................

    Hope that helps?

+ 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