早教吧作业答案频道 -->其他-->
如图,怎样自定义一个函数能直接将各行结果汇总求和PublicFunctionSumf(rAsRange)AsDoubleDimiAsIntegerDimjAsIntegerDimrtnAsDoubleDimevlAsDoublertn=0Fori=1Tor.Rows.CountForj=1Tor.Columns.Cou
题目详情
如图,怎样自定义一个函数能直接将各行结果汇总求和
Public Function Sumf(r As Range) As Double
Dim i As Integer
Dim j As Integer
Dim rtn As Double
Dim evl As Double
rtn = 0
For i = 1 To r.Rows.Count
For j = 1 To r.Columns.Count
evl = Application.Evaluate(r.Cells(i, j))
rtn = rtn + evl
Next j
Next i
Sumf = rtn
End Function
我编写了以上代码但不知在哪里有错,结果不对.
没人回答,不过经过两天的查找资料和分析终于解决问题了,Public Function Sumf(r As Range) As Double
Dim i As Integer
Dim j As Integer
Dim x As String
Dim rtn As Double
Dim evl As Double
rtn = 0
For i = 1 To r.Rows.Count
For j = 1 To r.Columns.Count
If r.Cells(i, j) = "" Then
x = 0
Else
x = r.Cells(i, j)
End If
evl = Application.Evaluate(x)
rtn = rtn + evl
 
Public Function Sumf(r As Range) As Double
Dim i As Integer
Dim j As Integer
Dim rtn As Double
Dim evl As Double
rtn = 0
For i = 1 To r.Rows.Count
For j = 1 To r.Columns.Count
evl = Application.Evaluate(r.Cells(i, j))
rtn = rtn + evl
Next j
Next i
Sumf = rtn
End Function
我编写了以上代码但不知在哪里有错,结果不对.
没人回答,不过经过两天的查找资料和分析终于解决问题了,Public Function Sumf(r As Range) As Double
Dim i As Integer
Dim j As Integer
Dim x As String
Dim rtn As Double
Dim evl As Double
rtn = 0
For i = 1 To r.Rows.Count
For j = 1 To r.Columns.Count
If r.Cells(i, j) = "" Then
x = 0
Else
x = r.Cells(i, j)
End If
evl = Application.Evaluate(x)
rtn = rtn + evl
 
▼优质解答
答案和解析
不用函数也行,用数据菜单下的列表 就可以实现 比函数方便
看了如图,怎样自定义一个函数能直接...的网友还看了以下:
一般地,设函数f(x)的定义域为I如果对于属于I内某个区间上的任意两个自变量的值x1、x2,当x1< 2020-03-30 …
这里的trace是什么意思?例子//在调试窗口打印小于一百的偶数的平方for(INTi=0;i<1 2020-05-20 …
一般地,设函数y=f(x)的定义域为I,如果存在实数M满足:①对于任意的x∈I,都有f(x)≤M; 2020-06-25 …
一根直径为d均匀电阻丝,当两端电压为U时,通过电流为I,如果将此电阻丝均匀拉长,使直径变为d/2, 2020-07-04 …
matlabfprintf怎样输出0?fprintf(fid,'%5.0d\n',G(i));如果 2020-07-14 …
一般的,设函数Y=F(x)的定义域为I,如果存在实数M满足:(1)对于任意的x∈I,都有F(x)≤ 2020-08-01 …
(-1)^(-1/2)=?i还是-i?为啥如果先算-1的-1次方(这一步得到答案为-1)再继续算其的 2020-11-01 …
以辅音字母+y结尾的双音节词,比较级要变y为i加er;那么dry,shy等单音节词的比较级是否要变y 2020-12-07 …
函数最大值为什么一般的,设函数Y=f(X)的定义域为I,如果存在实数M满足(1)对于任意的X属于I, 2020-12-08 …
HNO3能不能氧化I如果硝酸能氧化I离子,那么怎么解释:I离子检验中先加硝酸酸化,再加硝酸银,如果硝 2020-12-08 …