如何将 SERIESSUM 函数转换为 VB6?
关于每日剂量Excel网站,由已故的Frank Kabel编写,有一些可以代替ATP函数的公式。 作为一名 Excel 专家,我正在努力将 Excel 转换为 VB6(到目前为止!)。 (一旦 NDA 用完,我可能会想到为什么我要这样做。)
我遇到的问题是代表 SERIESSUM 的代码,即,
=SUMPRODUCT(coefficients,x^(n+m*(ROW(INDIRECT("1:"&ROWS(coefficients)))-1)))
现在我已经能够相当简单地渲染 SUMPRODUCT 和 ROWS 函数
Public Function SUMPRODUCT(a1 As Variant, a2 As Variant) As Double
Dim dRes As Double
Dim dVal As Double
Dim i As Long
If LBound(a1) = LBound(a2) And UBound(a1) = UBound(a2) Then
For i = LBound(a1) To UBound(a1)
dVal = a1(i) * a2(i)
dRes = dRes + dVal
Next
End If
SUMPRODUCT = dRes
End Function
Public Function ROWS(a1 As Variant)
ROWS = UBound(a1) - LBound(a1) + 1
End Function
我还没有“明白”的是
x^(n+m*(ROW(INDIRECT("1:"&ROWS(coefficients)))-1))
如何计算为数组- 该数组可能包含
什么 有 Excel 专家吗?
On the Daily Dose of Excel website, written by the late Frank Kabel, there are some formulae which can stand in for ATP functions. Not being an Excel guru, I'm struggling with converting one (so far!) to VB6. (Why I'm doing this I may relate once the NDA runs out.)
The problem I'm having is with the code standing in for SERIESSUM, namely,
=SUMPRODUCT(coefficients,x^(n+m*(ROW(INDIRECT("1:"&ROWS(coefficients)))-1)))
Now the SUMPRODUCT and ROWS functions I've been able to render fairly simply with
Public Function SUMPRODUCT(a1 As Variant, a2 As Variant) As Double
Dim dRes As Double
Dim dVal As Double
Dim i As Long
If LBound(a1) = LBound(a2) And UBound(a1) = UBound(a2) Then
For i = LBound(a1) To UBound(a1)
dVal = a1(i) * a2(i)
dRes = dRes + dVal
Next
End If
SUMPRODUCT = dRes
End Function
Public Function ROWS(a1 As Variant)
ROWS = UBound(a1) - LBound(a1) + 1
End Function
What I don't 'get' yet is
- how
x^(n+m*(ROW(INDIRECT("1:"&ROWS(coefficients)))-1))
evaluates to an array - and what that array might contain
Any Excel gurus out there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果系数有 5 行,则将返回数组 {1,2,3,4,5}。 其余的进展是
结果数组根据系数进行“级数求和”。
您可以通过在公式的突出显示部分上使用 Ctrl+= 来查看 Excel 公式栏中的进度。 公式栏中可以显示的字符数有限制,因此如果系数有很多行,您可能会收到错误“公式太长”
在公式栏中,选择 ROW(INDIRECT("1:"& ;ROWS(系数)))-1 并按 Ctrl+=。 然后选择公式的另一部分,确保匹配左括号和右括号,然后按 Ctrl+=。 您可以迭代此过程,直到计算出整个公式。 完成后,请务必退出单元格,以免丢失原始公式。
另请参阅此处的第 474 集。
If coefficients has 5 rows, this will return the array {1,2,3,4,5}. The rest of the progression is
That resulting array gets 'series summed' against coeffecients.
You can see the progression in Excel's formula bar by using Ctrl+= on highlighted parts of the formulas. There is a limit on how many characters you can display in the formula bar, so if coefficients has a lot of rows, you may get the error "formula too long"
In the formula bar, select ROW(INDIRECT("1:"&ROWS(coefficients)))-1 and press Ctrl+=. Then select another portion of your formula, making sure you match opening and closing parentheses, and hit Ctrl+=. You can iterate this until you have the whole formula calculated. When you're done, be sure to ESCAPE out of the cell so you don't lose your original formula.
See also Episode 474 here.