
Option Explicit
Const NUM As Long = 15
Sub abc()
Dim a, i, m, n, t, d
a = [b2:b6].Value '5题必考,自己修改区域
Set d = CreateObject("scripting.dictionary")
For i = 1 To UBound(a)
d(a(i, 1)) = 1
Next
a = Range("a2:a" & [a2].End(xlDown).Row).Value
For i = 1 To UBound(a)
If Not d.exists(a(i, 1)) Then m = m + 1: a(m, 1) = a(i, 1)
Next
If m < NUM Then MsgBox "!": Exit Sub
For i = 1 To NUM '随机取非必考的num题目
n = Int(Rnd * (m - i + 1)) + i
t = a(i, 1): a(i, 1) = a(n, 1): a(n, 1) = t
Next
[c2].Resize(NUM) = a
End Sub