|
- Public Sub tt()
- Dim dic1 As New Collection, dic2 As New Collection, i&, m&, n&, arr
- arr = Sheet1.Range("b2:c101").Value
- Sheet1.Range("d2:d31").ClearContents
- For i = 1 To 100
- If arr(i, 2) = "??" Then
- dic1.Add arr(i, 1)
- Else
- dic2.Add arr(i, 1)
- End If
- Next
- ReDim arr(1 To 30, 1 To 1)
- For m = 1 To 30
- n = WorksheetFunction.RandBetween(1, dic1.Count)
- arr(m, 1) = dic1(n)
- dic1.Remove (n)
- Next
- Sheet1.Range("d2:d31").Value = arr
- ReDim arr(1 To 20, 1 To 1)
- For m = 1 To 20
- n = WorksheetFunction.RandBetween(1, dic2.Count)
- arr(m, 1) = dic2(n)
- dic2.Remove (n)
- Next
- Sheet1.Range("e2:e21").Value = arr
- Set dic1 = Nothing
- Set dic2 = Nothing
- End Sub
复制代码
|
|