excel固定几个数值随机排列

发布网友 发布时间:2022-03-08 05:56

我来回答

3个回答

热心网友 时间:2022-03-08 07:25

Sub abc()
For i = 1 To 10
Cells(i, "A") = Int(Rnd() * 50) + 1
If i > 1 Then
For j = 1 To i - 1
If Cells(i, "A") = Cells(j, "A") Then
i = i - 1
Exit For
End If
Next j
For j = 1 To i - 1
If Cells(i, "A") < Cells(j, "A") Then
b = Cells(i, "A")
Cells(i, "A") = Cells(j, "A")
Cells(j, "A") = b
End If
Next j
End If
Next i
End Sub

热心网友 时间:2022-03-08 08:43

:
Sub abc()
For i = 1 To 10
Cells(i, "A") = Int(Rnd() * 50) + 1
If i > 1 Then
For j = 1 To i - 1
If Cells(i, "A") = Cells(j, "A") Then
i = i - 1
Exit For
End If
Next j
For j = 1 To i - 1
If Cells(i, "A") < Cells(j, "A") Then
b = Cells(i, "A")
Cells(i, "A") = Cells(j, "A")
Cells(j, "A") = b
End If
Next j
End If
Next i
End Sub

热心网友 时间:2022-03-08 10:18

假设你的数据在A列,在B1中输入:=RAND()
然后下拉公式,再以B列进行排序.

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com