我有任务列表和有限的可用资源,我想根据任务的可用性将资源分配给任务。我已经编写了代码,以根据每个人的上一个任务为其分配新的可用时间,但是我需要为下一个可用时间添加一个“等待”并分配该时间。因此,我希望在任务启动时没有可用的磁盘,我希望它等待下一个可用的磁盘。请让我知道是否需要澄清。
这就是我所拥有的:
Public Sub TractorAssignment()
Dim rDrivers As Range
Dim vAvailable_Times As Variant
Dim rAssignments As Range
Dim rJob As Range
Dim rStart_Times As Range
Dim iloop As Integer
Set rDrivers = ActiveWorkbook.Worksheets("Parameters").Range("M14").CurrentRegion
Set rDrivers = rDrivers.Offset(1).Resize(rDrivers.Rows.Count - 1)
Set rAssignments = ActiveSheet.Range("BO6").CurrentRegion
Set rAssignments = rAssignments.Offset(1).Resize(rAssignments.Rows.Count - 1)
Set rStart_Times = rAssignments.Columns(10)
vAvailable_Times = Application.Transpose(rDrivers.Columns(2))
For Each rJob In rStart_Times.Rows
For iloop = LBound(vAvailable_Times) To UBound(vAvailable_Times)
If rJob.Value > vAvailable_Times(iloop) Then
rJob.Offset(, 5).Value = rDrivers.Cells(iloop, 1)
vAvailable_Times(iloop) = rJob.Offset(, 4)
Exit For
End If
Next
Next