怎样用Excel把10个数字中的4个数字进行组合,并列出来
答案:2 悬赏:40 手机版
解决时间 2021-11-12 01:56
- 提问者网友:别再叽里呱啦
- 2021-11-11 10:53
怎样用Excel把10个数字中的4个数字进行组合,并列出来
最佳答案
- 五星知识达人网友:迷人又混蛋
- 2021-11-11 12:27
在SHEET1表A1单元格录入10位数字字符,例如1234560000
将排列组合结果显示在SHEET1表B列中
Public Sub aaa()
Dim Mstr1 As String, Mstr2 As String, MStr3 As String
n = 1
For i = 1 To 10
Mstr1 = Mid(Sheet1.Range("A1"), i, 1)
For j = 1 To 10
If j <> i Then
Mstr2 = Mstr1 & Mid(Sheet1.Range("A1"), j, 1)
For k = 1 To 10
If k <> j And k <> i Then
MStr3 = Mstr2 & Mid(Sheet1.Range("A1"), k, 1)
For l = 1 To 10
If l <> k And l <> j And l <> i Then
Sheet1.Range("B" & n) = MStr3 & Mid(Sheet1.Range("A1"), l, 1)
n = n + 1
End If
Next
End If
Next
End If
Next
Next
Sheet1.Range("B1:B" & Sheet1.Range("B30000").End(xlUp).Row).RemoveDuplicates Columns:=1, Header:=xlNo
End Sub
不过通过编程结果显示,是1045种,而不是210种哦
将排列组合结果显示在SHEET1表B列中
Public Sub aaa()
Dim Mstr1 As String, Mstr2 As String, MStr3 As String
n = 1
For i = 1 To 10
Mstr1 = Mid(Sheet1.Range("A1"), i, 1)
For j = 1 To 10
If j <> i Then
Mstr2 = Mstr1 & Mid(Sheet1.Range("A1"), j, 1)
For k = 1 To 10
If k <> j And k <> i Then
MStr3 = Mstr2 & Mid(Sheet1.Range("A1"), k, 1)
For l = 1 To 10
If l <> k And l <> j And l <> i Then
Sheet1.Range("B" & n) = MStr3 & Mid(Sheet1.Range("A1"), l, 1)
n = n + 1
End If
Next
End If
Next
End If
Next
Next
Sheet1.Range("B1:B" & Sheet1.Range("B30000").End(xlUp).Row).RemoveDuplicates Columns:=1, Header:=xlNo
End Sub
不过通过编程结果显示,是1045种,而不是210种哦
全部回答
- 1楼网友:毛毛
- 2021-11-11 13:01
请举个例子看看。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯