gpt4 book ai didi

Excel UDF 对具有特定背景颜色的单元格求和

转载 作者:行者123 更新时间:2023-12-04 22:18:45 26 4
gpt4 key购买 nike

关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。












此问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-topic在这里,这个问题的解决方式不太可能帮助 future 的读者。


去年关闭。







Improve this question




试图总结具有特定背景颜色的单元格总数。
在此处遵循本教程:https://www.exceltrick.com/how_to/sum-cells-based-on-background-color/
尝试实现以下 UDF 时,我在第 3 行(从 Dim ColIndex 开始)收到语法错误:

Function SumByColor(CellColor As Range, rRange As Range)
Dim cSum As Long
Dim ColIndex As Integer ColIndex = CellColor.Interior.ColorIndex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then cSum = WorksheetFunction.SUM(cl, cSum)
End If
Next cl SumByColor = cSum
End Function
有谁知道 UDF 出了什么问题?
MS Office 版本:MS Office Professional Plus 2016。
谢谢!

最佳答案

你错过了一些线端

Function SumByColor(CellColor As Range, rRange As Range)
Dim cSum As Long
Dim ColIndex As Integer
ColIndex = CellColor.Interior.ColorIndex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.SUM(cl, cSum)
End If
Next cl
SumByColor = cSum
End Function

关于Excel UDF 对具有特定背景颜色的单元格求和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66317852/

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