View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Cecilkumara Fernando[_2_] Cecilkumara Fernando[_2_] is offline
external usenet poster
 
Posts: 93
Default Priority & Ranking Assignments

BKing,
In a new sheet copy your list "people" to A1 with headers in row1
copy your list "items" to I1 with headers in row1
so the list "people" will be in range A1:Exx
and the list "items" will be in range I1:Jyy
Copy both subs to a module and run Sub ass()
from the new sheet you just made
HTH
Cecil

Sub ass()

Range("F1").Formula = "Assignment"

LRTB1 = Range("A" & Rows.Count).End(xlUp).row
LRTB2 = Range("I" & Rows.Count).End(xlUp).row

Range("A1:E" & LRTB1).Sort Key1:=Range("B2"), _
Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

Range("I1:J" & LRTB2).Sort Key1:=Range("J2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom

For j = i To 3
Application.Run "priority"
Next j

LRAss = Range("F" & Rows.Count).End(xlUp).row + 1

RemRow = 2 + LRTB1 - LRAss

With Range("I2:J" & RemRow)
..Copy Destination:=Range("F" & LRAss)
..Delete Shift:=xlUp
End With

Range("C1:E1").EntireColumn.Delete

End Sub

Sub priority()

LRTB1 = Range("A" & Rows.Count).End(xlUp).row
LRTB2 = Range("I" & Rows.Count).End(xlUp).row
LRAss = Range("F" & Rows.Count).End(xlUp).row + 1

Range("G" & LRAss).Value = Range("C1")

For i = LRAss To LRTB1
If Not IsError(Evaluate("match(C" & i & "," & _
Range("I1:I" & LRTB2).Address & ",0)")) Then
foundit = Evaluate("match(C" & i & "," & _
Range("I1:I" & LRTB2).Address & ",0)")
Range("F" & i).Value = Range("I" & foundit).Value
Range("I" & foundit, "J" & foundit).Delete Shift:=xlUp
End If
Next i

Range("A" & LRAss & ":F" & LRTB1).Sort Key1:=Range("F2"), _
Order1:=xlDescending, Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom

Range("D1:E" & LRTB1).Cut Destination:=Range("C1:D" & LRTB1)

End Sub

"BKing" wrote in message
...
Hi, I could use some assistance with code that makes
assignments based on a priority in one group with a
ranking in another group.

I have master 2 lists, people and items.
The people contains: Name, experience, priority1,
priority2, priority3.
The items list contains: Name, ranking.

On a separate daily task worksheet assignments need to be
made to the items that are available with the people that
are available. The items available and people available
can be different each day.

The items can be in one or more of the three priorities,
and the items ranking may not be unique.

However, as soon the logic is hit, don't consider that
person or item again.

The order for assignments is, check priority1 for all
people available, then priority2, then priority3. If the
item is found under a persons priority, assign the item to
them on the daily task sheet and do not consider them for
any other items, or that item for any other person.

If the item is not found in one of the 3 priorities,
assign the highest ranked item (1 is highest) to the most
experienced person (highest number is the most). Don't
consider that person or item again.

If the item is still not assigned, return unassigned.

e.g.
People:
Name=Name1
Experience=6
priority1= Carrots
priority2=Grapes
priority3=Grapefruit

Name=Name2
Experience=5
priority1= Squash
priority2=Apples
priority3=Bananas

Name=Name3
Experience=6
priority1= Apples
priority2=Squash
priority3= Tomatoes

Items
Name=Apples
Ranking=1

Name=Grapes
Ranking=1

Name=Oranges
Ranking=3

Name=Tomatoes
Ranking=2

Name=Watermelon
Ranking=6

Using the above people and items if apples, tomatoes,
oranges and watermelon are available
Apples are assigned to Name3. (Found first it priority1)
Tomatoes are assigned to Name1 (most experiences, highest
ranking)
Oranges are assigned to Name2 (next most experienced, next
highest ranking)
Watermelon is "unassigned"

Thanks, if you are sill here.