Excel表里面有好多数字 需要组合成一个总数怎么弄

2023-03-03 17:37

3个回答

我试用VBA试一试,共有113个不重复的组合可累加为11709的:

以下是求由9个数组合的程序,求其它个数的可删减其程序,我用了3 个多小时求出以上结果的。

Sub TEST()
Dim a  As Integer, b  As Integer, c  As Integer, d  As Integer, e  As Integer, f  As Integer, g  As Integer, h  As Integer, i  As Integer, j As Integer, k As Integer
k = 0
For b = 1 To 48
For c = b + 1 To 49
For d = c + 1 To 50
For e = d + 1 To 51
For f = e + 1 To 52
    If Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) + Cells(f, 1) > 11709 Then
        Exit For
    Else
Cells(1, 16) = "'" & b & c & d & e
For g = f + 1 To 53
    If Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) + Cells(f, 1) + Cells(g, 1) > 11709 Then
        Exit For
    Else
For h = g + 1 To 54
    If Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) + Cells(f, 1) + Cells(g, 1) + Cells(h, 1) > 11709 Then
        Exit For
    Else
For i = h + 1 To 55
    If Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) + Cells(f, 1) + Cells(g, 1) + Cells(h, 1) + Cells(i, 1) > 11709 Then
        Exit For
    Else
For j = i + 1 To 56
    If Cells(b, 1) + Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) + Cells(f, 1) + Cells(g, 1) + Cells(h, 1) + Cells(i, 1) + Cells(j, 1) > 11709 Then
        Exit For
    Else
    If Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) + Cells(f, 1) + Cells(g, 1) + Cells(h, 1) + Cells(i, 1) + Cells(j, 1) = 11709 Then
'    If Cells(a, 1) + Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) + Cells(f, 1) + Cells(g, 1) + Cells(h, 1) + Cells(i, 1) + Cells(j, 1) = 11709 Then
        k = k + 1
'        Cells(k, 3) = Cells(a, 1)
        Cells(k, 4) = Cells(b, 1)
        Cells(k, 5) = Cells(c, 1)
        Cells(k, 6) = Cells(d, 1)
        Cells(k, 7) = Cells(e, 1)
        Cells(k, 8) = Cells(f, 1)
        Cells(k, 9) = Cells(g, 1)
        Cells(k, 10) = Cells(h, 1)
        Cells(k, 11) = Cells(i, 1)
        Cells(k, 12) = Cells(j, 1)
    End If
    End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
Next
Next
Next
Next
End Sub
这个要求要用vba编程来实现,我研究一下看
求和,选中上面的数字,工具栏里点自动求和
相关问答
excel中,实现排列组合,这个怎么弄?
1个回答2022-11-26 22:48
1。在C列输入=, 然后选中A列你要组合的数据,接着在C列输入 =A &"-"&B 就可以了 2.同上。在B列选中你要的数据就可以了
excel中名次排名怎么弄
1个回答2022-12-30 19:50
主要就是把这样的名字一一的定位,然后人名也要添加入,把分类分类表格做好之后进行排序就可以。
excel名次等级怎么弄
1个回答2023-02-13 05:02
方法一 1. 首先,打开一个Excel表格. 2. 然后将表格全部选中,不要选标题哦. 3. 然后再点击上方工具栏的【数据】,再点击【排序】. 方法二 打开【excel】,在成绩等级的第一个单元...
全文
excel的随机点名怎么弄
1个回答2023-01-18 15:21
在单元格中输入公式:=INDEX(B1:B32,INT(RAND()*33)) 每次刷新都可以选择一个名字
excel表格无边框怎么弄
1个回答2022-12-13 00:37
选定单元格以后,在边框功能里面进行设置即可。 注意表格里面单元格的范围框线是任何时候都存在的,我们选择框线选择线条颜色以后才决定打印的时候是不是有框线。
excel等级怎么弄优,良
2个回答2023-02-23 01:56
用IF()函数,并且多层套用,不超过七层, 比如,=IF(A1>=90,"优",IF(A1>=80,"良",IF(A1>=60,"及格",“不及格”))) 这时候就可以根据A1内的数据判断等级了。
excel 随机组合,弄成4个不重复的,求高手
1个回答2022-09-21 01:02
你要的数据样本都是在A列么?如果这样就简单了。 假设你的数据有X个,分别在A1-AX单元格里,那么要抽取的数据可以是=address(int(x*rand()),1,1,) 这是利用随机数提取的,x的...
全文
怎么用Excel把人员名单随机分成几个组?
1个回答2022-12-27 03:05
用VBA超级简单
做一个excel微课需要讲些什么
1个回答2024-01-18 23:57
EXCEL启动保存退出,Excel和sheet有什么区别,单元拖动都有什么效果,单元格自动填充,排序。 要看你对应得人群水平, 如果初学可以上面的内容,否则,公式,宏也是有很多要讲的。
热门问答