excel中怎么给123456这些数字按照位置不同排序?
发布网友
发布时间:2022-03-19 13:05
我来回答
共4个回答
懂视网
时间:2022-03-19 17:26
excel排名的设置方法:打开Excel表格,输入你需要的数据,然后选中一个名次的单元格,
在单元格输入公式,=RANK(H2,H&2:H$8,0) 按回车键即可,
然后点击单元格下拉就完成了。
热心网友
时间:2022-03-19 14:34
'这么麻烦,只能用VBA了,就是排列组合。
Sub arrange()
Dim str, str1, str2, str3, str4, str5, cnt, cut
str = "123456"
Count = 0
cnt = 1
cut = 1
For i = 1 To Len(str)
str1 = Replace(str, Mid(str, i, 1), "")
For j = 1 To Len(str1)
str2 = Replace(str1, Mid(str1, j, 1), "")
For k = 1 To Len(str2)
str3 = Replace(str2, Mid(str2, k, 1), "")
For l = 1 To Len(str3)
str4 = Replace(str3, Mid(str3, l, 1), "")
For m = 1 To Len(str4)
str5 = Replace(str4, Mid(str4, m, 1), "")
For n = 1 To Len(str5)
Cells(cnt, cut) = Mid(str, i, 1) & Mid(str1, j, 1) & Mid(str2, k, 1) & Mid(str3, l, 1) & Mid(str4, m, 1) & Mid(str5, n, 1)
cnt = cnt + 1
Count = Count + 1
If cnt = 61 Then
cnt = 1
cut = cut + 1
End If
Next
Next
Next
Next
Next
Next
MsgBox Count
End Sub
不懂vba就不好办了,你看下附件吧。Alt+F11可打开代码窗口。
热心网友
时间:2022-03-19 15:52
用如下VBA程序
Private Sub CommandButton1_Click()
Dim i1%, i2%, i3%, i4%, i5%, i6%, k As Long
Range("A:A").ClearContents
k = 0
For i1% = 1 To 6
For i2% = 1 To 6
For i3% = 1 To 6
For i4% = 1 To 6
For i5% = 1 To 6
For i6% = 1 To 6
If i1% <> i2% And i1% <> i3% And i1% <> i4% And i1% <> i5% And i1% <> i6% _
And i2% <> i3% And i2% <> i4% And i2% <> i5% And i2% <> i6% _
And i3% <> i4% And i3% <> i5% And i3% <> i6% _
And i4% <> i5% And i4% <> i6% And i5% <> i6% Then
k = k + 1
Range("A" & k) = i1% & i2% & i3% & i4% & i5% & i6%
End If
Next i6%
Next i5%
Next i4%
Next i3%
Next i2%
Next i1%
End Sub
热心网友
时间:2022-03-19 17:27
给个图片或者附件吧?