samedi 14 décembre 2019

Randomly Assign Employees with Percentage to Tasks

I was working in a previous macro that makes me a lot of problems like (if #Tasks < #Employees) macro doesn't work, or like percent Values that I think does not work properly

I share a part of the macro that assign Employees to Tasks

Dim perc As Double

Sheets("TASKs").Select
Range("A2").Select
Selection.End(xlDown).Select
cnt = ActiveCell.Row - 1
Sheets("TO_ASSIGN").Select

If ThisWorkbook.Sheets("CATALOGO").Range("SUM_PERCENT").Value = 0.01 Then
i = 2
K = 2
perc = 0
Do While Cells(i, 1).Value <> ""
emp = Cells(i, 1).Value
perc = (Cells(i, 2).Value * cnt) + perc

For j = K To perc + 1

Sheets("TASKs").Select
Cells(K, 2).Value = emp
K = K + 1

Next j
'
i = i + 1
Sheets("TO_ASSIGN").Select
Loop
Sheets("TASKs").Select
Else
MsgBox "Asigne los porcentajes correctamente"
Exit Sub
End If

I really forgot where I found this macro, it was working fine for a while but then, this kind of problem when #Task lower than #Employees, macro does nothing

Then I found in the next post Randomly Assign Employees to Tasks in the comments,the [Command Button] one, a macro that works fine if (#Tasks < #Employees).
Credits to the owner @K.Dᴀᴠɪs

I would like to add a Percentage for each Employee in this other macro from previous post.

Can anyone help me with this?




Aucun commentaire:

Enregistrer un commentaire