Sub 随机取数()
Dim k, i, j, n, sj, rng As Range
i = Application.WorksheetFunction.CountA(Sheet1.[A:A])
n = Application.WorksheetFunction.CountA(Sheet1.[D:D])
If i - n < 4 Then Exit Sub
Do
sj = Int((i - 2 + 1) * Rnd + 2)
j = Sheet1.Cells(Rows.Count, "D").End(xlUp).Row
Set rng = Sheet1.Range("D:D").Find(Cells(sj, 1))
If rng Is Nothing Then
If k = 0 And j <> 1 Then j = j + 1
Sheet1.Cells(j + 1, 4) = Sheet1.Cells(sj, 1)
k = k + 1
End If
Loop Until k = 4
End Sub