Option Explicit Sub abc() Dim i, j, n, s(2) s(0) = "0123456789" '数字 s(1) = "abcdefghijklmnopqrstuvwxyz" & _ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" '字母 s(2) = "~`!@#$%^&*()_-+={}[]|\:;?/>.<," '符号 ReDim a(1 To 10 ^ 3, 1 To 1) As String, p(UBound(s)) For i = 1 To UBound(a) For j = 1 To 8 n = Int(Rnd * (UBound(s) + 1)): p(n) = 1 a(i, 1) = a(i, 1) & Mid(s(n), Int(Rnd * Len(s(n))) + 1, 1) Next For j = 0 To UBound(p) If p(j) = 0 Then n = -1 p(j) = 0 Next If n = -1 Then a(i, 1) = vbNullString: i = i - 1 Next With [a:a] .ClearContents .Resize(UBound(a)) = a End With End Sub