目前我有这个:
在这个1º按钮中,我会询问作业的数量,并将B栏中1到10个作业的时间随机化。
Private Sub Button1_Click()
Worksheets("Sheet1").Activate
Range("A1").Value = "tarefa"
Range("B1").Value = "tempo"
Dim N As Long
N = Application.InputBox(Prompt:="N tarefas?(ex. 7 = 6 tarefas)", Type:=1)
If N > Rows.Count Then
N = Rows.Count
End If
For Z = 2 To N
Cells(Z, 1) = Z - 1
Cells(Z, 2) = WorksheetFunction.RandBetween(1, 10)
Next Z
Range("E1").Value = "total tarefas"
Range("E2").Value = N - 1
Range("E7").Value = "ultima celula em A"
Range("E8").Value = Range("A1").End(xlDown).Row
End Sub
在这个2º按钮中,我将B列中的值从最大到最小排序我询问机器数量并列出机器我还根据作业确定需要制作的列数和选择的机器数量。
Private Sub Button2_Click()
Worksheets("Sheet1").Activate
Columns("A:B").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("L1").Value = "máqs a usar?"
Dim N As Long
M = Application.InputBox(Prompt:="N maq?(ex. 3 = 2 maq)", Type:=1)
If M < 3 Then
M = 3
End If
If M > Columns.Count Then
M = Columns.Count
End If
Range("E4").Value = "total maqs"
Range("E5").Value = M - 1
For i = 2 To M
Cells(i, 12) = i - 1
Next i
Range("E10").Value = "colunas a fazer"
colunasAfazer = (Cells(2, 5) / Cells(5, 5))
Range("E11").Value = colunasAfazer
Range("E13").Value = "arredondamento"
Range("E14").Value = Round(Cells(11, 5) + 0.44)
arredondado = Range("E14").Value
For q = 1 To M
w = q + 1
问题来到这里我试图让程序从第2行开始(w = 2)列L看看是否为空,如果不是(因为它将在那里列出机器)然后转到M列并写第一,第二,第三等等更大数量的B列只做这个我没有问题。
Select Case Cells(w, 12)
Case Is = ""
Case Else
Cells(w, 13) = WorksheetFunction.Large(Columns(2), q)
End Select
Next q
End Sub
我尝试过但未能做到的是将其设为自动而不是必须执行以下某种工作方式
Select Case Cells(w, 12)
Case Is = ""
Case Else
Cells(w, 13) = WorksheetFunction.Large(Columns(2), q)
End Select
Select Case Cells(w, 13)
Case Is = ""
Case Else
Cells(w, 14) = WorksheetFunction.Large(Columns(2), w + M - 1)
End Select
Next q
End Sub
任何人都可以帮我自动使用正确的q值填充必要的单元格,并选择任意数量的作业和机器吗?