如何计算excel中使用VBA的注释单元格?
问题描述:
我试图计算在Excel注释细胞与列这个VBA代码,但它返回在整个工作表所有评论。我如何更改此代码来计算单元格只在一行或一列中形成n1..n2?如何计算excel中使用VBA的注释单元格?
Function CountComments(xCell As Range)
Application.Volatile
CountComments = xCell.Parent.Comments.Count
End Function
例如:
A1 = CountComments(G2:G7)
A2 = CountComments(H2:H7)
他们返回一个结果
答
你可以试试这个,它计数有意见的小区的数量
Function CountComments(xCells As Range)
Dim x As Range
On Error Resume Next
For Each x In xCells
L = -1
L = Len(x.Comment.Text)
If L >= 0 Then Counts = Counts + 1
Next
CountComments = Counts
End Function