1. The import list file, list number according to actual 2, normal post fixed number 2 people, special post has three, the three jobs assigned number changes over a list of the number, the number of jobs in 1-2 change 3. The random grouping, researchers don't repeat 4. According to the output of the position: name
CodePudding user response:
To import, then random sequence, after coming to an end, in accordance with the requirements of the number of people you want to a few people in order to grasp a few people out
CodePudding user response:
Have three special post, please send people (at least send 1 individual)?
CodePudding user response:
Const workernum=20 Dim aryTestName (1 To workernum) As String Dim As Integer I Dim STRTMP As String Dim idx1 As an Integer, idx2 As Integer 'simulation personnel into arrays, for example here less than 26 people, so use letters to distinguish between staff name For I=1 To workernum AryTestName (I)="staff" & amp; CRH (64 + I) Next Randomize Now () 'get a random seed
For I=1 To 10000 '10000 times random sequence order, random adjustment sequence of the number of Suggestions For more than 10 times the number of array elements Idx1=Int (Rnd * (UBound (aryTestName) - LBound (aryTestName) + 1)) + LBound (aryTestName) 'to generate a random integer array subscript range Idx2=Int (Rnd * (UBound (aryTestName) - LBound (aryTestName) + 1)) + LBound (aryTestName) 'generating a random integer array subscript range 'the two subscripts corresponding array element for exchange STRTMP=aryTestName (idx1) AryTestName (idx1)=aryTestName (idx2) AryTestName (idx2)=STRTMP Next
Output 'For I=LBound (aryTestName) To UBound (aryTestName) The Debug. Print "first" & amp; Fix ((I - 1)/5) + 1 & amp; "Group" & amp; The IIf (((I - 1) Mod 5) & lt; 2, "normal jobs" & amp; ((I - 1) Mod 5) + 1, "special position" & amp; ((I - 1) Mod 5) - 1) & amp; ":" & amp; AryTestName (I) Next
A set of output: Group 1 normal posts 1: personnel G Group 1 normal posts 2: personnel H Group 1 special post 1: personnel C Group 1 special post 2: personnel E Group 1 special post 3: personnel T 2 set position 1: normal personnel I Group 2 normal posts 2: personnel L Group 2 special post 1: personnel S Group 2 special post 2: personnel M 2 set of special post 3: personnel P 3 groups of normal post 1: personnel O Group 3 normal posts 2: personnel F 3 set special post 1: personnel N Group 3 special post 2: personnel D Group 3 special post 3: personnel R Group of normal post 1:4 staff B 4 groups of normal posts 2: personnel Q Group 4 special post 1: personnel K A group of special post 2 4: personnel Set of special post 3 4: personnel J