|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Dim Code As Long ''' 设置一个登台顺序的记录,可有可无
- Sub Start()
- ''' 开始先设置所有人都是待选状态,大于0小于1标记
- With Sheet1
- r = .Cells(65536, 1).End(3).Row
- ar = .Range("a2:a" & r).Value
- .Range("d2:d" & r).Value = ar
- .Range("e2:e" & r).Formula = "=rand()"
- End With
- Code = 0
- End Sub
- Sub RandSelect()
- ''' 人员通过随机数打乱,实现随机抽取
- ''' 每次抽取完,登台的设置大于1,下次登台设置为0
- ''' 保证每次随机都会从剩下的人抽取
- With Sheet1
- If .Range("e3").Value >= 1 Then
- ''' 加一个判断提示已经抽取完毕
- MsgBox "全部登台讲演完毕,没有预讲演人员"
- Else
- ''' 抽取讲演人员,设置预备讲演人员
- .Range("D:E").Sort .Range("e1"), xlAscending, , , , , , xlYes
- Code = Code + 1
- .Range("e2").Value = Code
- If .Range("e3").Value < 1 Then .Range("e3").Value = -1
- End If
- End With
- End Sub
复制代码
|
|