gpt4 book ai didi

excel - 如何对一系列数字的第一位数字求和

转载 作者:行者123 更新时间:2023-12-02 12:53:15 31 4
gpt4 key购买 nike

以下数字从单元格 B5 开始:23 34 45 56 45 54我想对每个数字的第一个数字求和,并将结果显示在单元格 C9 中

我尝试对下面的代码进行不同的调整。

Sub sum_first_digit()

Dim colnum As Integer
Dim sumfirst As Integer

sumfirst = 0

For colnum = 2 To 7 Step 1
cellref = Cells(5, colnum)
sumfirst = sumfirst + (Left(celref, 1))
Next colnum

Range("C9").Value = sumfirst


End Sub

预计单元格 C9 的编号为 23。

实际是

Runtime Error 13: Type Mismatch

最佳答案

我不知道为什么公式不起作用。在C9使用中,

=SUMPRODUCT(--LEFT(B5:G5&0))
'an array formula that will skip over blank and text cells
=SUM(IFERROR(--LEFT(B5:G5&0), 0))

关于excel - 如何对一系列数字的第一位数字求和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54246731/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com