我需要帮助。我正在做一份报告并在细胞上插入注释。如何使用vba或公式计算excel中具有注释的特定值范围内的单元格?
发布于 2015-11-04 19:53:31
这里有一条路。它循环遍历您在范围内传递的每个单元格,并检查是否有注释。如果是这样,则将其添加到计数器中。如果在大范围内使用,这可能会非常昂贵,但至少应该让您开始:
在常规模块中添加:
Function CommentCounter(rng As Range) As Integer
Dim cell As Range
Dim counter As Integer
Dim currentComment As String
For Each cell In rng
On Error Resume Next
currentComment = cell.Comment.Text
If Len(currentComment) > 0 Then counter = counter + 1
currentComment = ""
Next cell
CommentCounter = counter
End Function只是看到了关于有一个特定的价值和评论的部分。这应该能让你:
Function CommentCounter(rng As Range) As Integer
Dim cell As Range
Dim counter As Integer
Dim currentComment As String
Dim specificValue As String
specificValue = "Something Specific"
For Each cell In rng
On Error Resume Next
currentComment = cell.Comment.Text
If cell.Value = specificValue And Len(currentComment) > 0 Then counter = counter + 1
currentComment = ""
Next cell
CommentCounter = counter
End Function发布于 2015-11-04 19:40:46
=COUNTIF(A:A;"comment")如果A:A指定要检查A的整个列,而不是A:A,则还可以使用A1: A3,这意味着检查A1、A2和A3。
编辑:
如果您想用注释(而不是“注释”)对单元格进行计数,我建议执行以下操作:
=COUNT(A1:A3) - COUNTBLANK(A1:A3)https://stackoverflow.com/questions/33530472
复制相似问题