Excel表里面有好多数字 需要组合成一个总数怎么弄
答案:4 悬赏:40 手机版
解决时间 2021-11-12 00:31
- 提问者网友:辞取
- 2021-11-11 06:43
Excel表里面有好多数字 需要组合成一个总数怎么弄
最佳答案
- 五星知识达人网友:你可爱的野爹
- 2021-11-11 08:09
我试用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
以下是求由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
全部回答
- 1楼网友:爱难随人意
- 2021-11-11 10:34
这个要求要用vba编程来实现,我研究一下看
- 2楼网友:旧脸谱
- 2021-11-11 09:15
求和,选中上面的数字,工具栏里点自动求和
- 3楼网友:雾月
- 2021-11-11 08:16
使用连接符&或者是使用CONCATENATE()函数都可以办到。
例如我想要连接A1,B1两个单元格中的数字,可以
用=A1&B1或者是=CONCATENATE(A1,B1)。
例如A1中的数字是520,B1中的数字是1314,在C1中键入前面所说的两种方法中的任意一种,均可以在C1中显示“5201314”。
以上方法中最终得到的结果会是一个“文本型数字”,如果再进行运算的话可能会出现错误,可以在公式前面再套用一个VALUE函数来解决这个小问题,即将公式修改为=VALUE(A1&B1)或者是=VALUE(CONCATENATE(A1,B1))就能解决了。
例如我想要连接A1,B1两个单元格中的数字,可以
用=A1&B1或者是=CONCATENATE(A1,B1)。
例如A1中的数字是520,B1中的数字是1314,在C1中键入前面所说的两种方法中的任意一种,均可以在C1中显示“5201314”。
以上方法中最终得到的结果会是一个“文本型数字”,如果再进行运算的话可能会出现错误,可以在公式前面再套用一个VALUE函数来解决这个小问题,即将公式修改为=VALUE(A1&B1)或者是=VALUE(CONCATENATE(A1,B1))就能解决了。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯