Auto Assign 20 Vans to 50 employees using Excel Vlookup

Katrix1982

New Member
Joined
Jul 21, 2020
Messages
2
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi,
I have to assign vans to my employees every morning. Each employee has a preference of which Van they want to use. Currently I am doing this by hand and comparing a sheet with employees and preferred van and trying to assign them to their van. I have 50 employees but 20 vans, so all 50 employees have a van preference from 1 to 20, repeated as needed. If it was 20 vans and 20 employees I would just use Vlookup to assign the vans. With 50 employees and 2 employees with same preference working the same day I am not sure how I can accomplish this.

I have a 3 sheets, one sheet (Vans) has van numbers 1 to 20. Second sheet has (Employees 50-75 with a preferred van number). I want to know if there is a way I can make it so that if an employee name is added to a (Blank) third sheet it would do a Vlookup to see which van the employee prefers, but if the Van is already assigned to another employee, it would pick another unassigned van for the employee.

I can get van preferences from employees where they pick 1st 2nd 3rd 4th 5th preferred van if needed.

Is there a way to do this in Excel?

Thanks.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
This is very difficult to do in Excel, and even in VBA it is a little tricky. It also requires more information on how you would decide between competing preferences.

If I were doing it, I would probably run down the list of employees, allocating vans where there is no competition, then go back through those where multiple employees want the same van, choosing randomly which one wins, then look at the further preferences of the losers. If one of them ran out of preferences, they would have to be allocated randomly.

I think you should pay someone to write code to do this. I expect it would take a few hours work (but not days).
 
Upvote 0
Hi Katrix1982,

Allocation of resources using Excel gets tricky and you usually need to become somewhat convoluted to avoid circular references. Here is my convoluted offering.

Here's your Blank sheet where you enter the names. I'm assuming that's where you designate who is on shift that particular day (NOTE: Allocations are made in the sequence entered so if two people prefer the same van then the first name on this sheet will be allocated the van).

Katrix1982.xlsx
ABC
1On ShiftVan
2EmilyVan12
3EthanVan09
4ElizabethVan03
5JacobVan01
6MichaelVan02
7MilaVan04
8DanielVan14
9EllaVan05
10AveryVan06
11HenryVan07
12JacksonVan08
13SofiaVan10
14 
Blank
Cell Formulas
RangeFormula
C2:C14C2=INDEX(Vans!$T$2:$T$100,MATCH(A2,Vans!$M$2:$M$101,0))


Here's your Employees sheet with the preferences.

Katrix1982.xlsx
ABCDEFG
1EmployeePref1Pref2Pref3Pref4Pref5Working Today
2Alexander 
3EmilyVan12Van03Van19Y
4EthanVan09Van12Y
5ElizabethVan12Van03Van09Van13Y
6JacobVan12Van03Y
7MichaelY
8MilaY
9DanielVan14Y
10EllaVan12Y
11AveryY
12HenryY
13JacksonY
14SofiaY
15Camila 
16Sebastian 
Employees
Cell Formulas
RangeFormula
G2:G16G2=IF(ISNA(MATCH(A2,Vans!$M$2:$M$100,0)),"","Y")


Here's the Vans sheet with the list of vans and who gets allocated to each. I'm using columns K to T as a work area to figure out the allocations but this could be cut & pasted to a hidden sheet if you want.

Cell Formulas
RangeFormula
M2:M17M2=INDEX(Blank!$A$2:$A$101,ROW()-1)
N2:N17N2=IF(M2=0,"",INDEX(Employees!$B$2:$B$100,MATCH(M2,Employees!$A$2:$A$100,0)))
O2:R17O2=IF($M2=0,"",IF(COUNTIF($N$1:N1,N2)>0,INDEX(Employees!C$2:C$100,MATCH($M2,Employees!$A$2:$A$100,0)),N2))
S2:S17S2=COUNTIF($R$1:R2,0)
T2:T17T2=IF(R2<>0,R2,INDEX($A$2:$A$21,AGGREGATE(15,6,ROW($A$2:$A$21)-ROW($A$1)/($K$2:$K$21=""),S2)))
C2:C17C2=IFERROR(INDEX($M$2:$M$100,MATCH(A2,$T$2:$T$100,0)),"")
K2:K17K2=IF(A2="","",IFERROR(INDEX($M$2:$M$100,MATCH(A2,$R$2:$R$100,0)),""))


I thought about randomizing the allocation so it's a litle more fair than relying on the sequence of names entered but the Excel RANDOM functions recalculate when any changes are made so I thought that might look confusing. Maybe a priority could be calculated based on the name and the date so it changes each day?
 
Upvote 0
@Katrix1982
While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Hi Katrix1982,

I've added some more convoluted logic to quasi randomize the Employee priority of getting their preferred van (when preferred vans are duplicated across employees) based on the first and last letters of employee name and date.

This means when your PC clocks over midnight the priorities will change for 24 hours, so giving a more fair allocation. Let me know if you want me to post that solution.
 
Upvote 0

Forum statistics

Threads
1,215,692
Messages
6,126,227
Members
449,303
Latest member
grantrob

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top