如何计算excel中注释中的字符数?

如何计算excel中注释中的字符数?,excel,excel-formula,vba,Excel,Excel Formula,Vba,我想知道是否有办法在excel中计算注释中的字符数?我必须把这些评论放到另一个应用程序中,我想知道是否可以得到字符数,因为该应用程序只接受150个字符,我知道有些评论的字符数不止这些,但我不想坐在那里把这些评论数出来。你不能通过公式来计算,但可以用VBA来计算 Dim com As Comment Dim ws As Worksheet Set ws = Sheets(1) For Each com In ws.Comments MsgBox Len(com.Text) Next com

我想知道是否有办法在excel中计算注释中的字符数?我必须把这些评论放到另一个应用程序中,我想知道是否可以得到字符数,因为该应用程序只接受150个字符,我知道有些评论的字符数不止这些,但我不想坐在那里把这些评论数出来。

你不能通过公式来计算,但可以用VBA来计算

Dim com As Comment
Dim ws As Worksheet
Set ws = Sheets(1)
For Each com In ws.Comments
    MsgBox Len(com.Text)
Next com
您还可以添加模块和创建函数

Function CountCommentCharacters(r As Range) As Integer
    CountCommentCharacters = Len(r.Comment.Text)
End Function

您不能通过公式执行此操作,但可以使用VBA执行此操作

Dim com As Comment
Dim ws As Worksheet
Set ws = Sheets(1)
For Each com In ws.Comments
    MsgBox Len(com.Text)
Next com
您还可以添加模块和创建函数

Function CountCommentCharacters(r As Range) As Integer
    CountCommentCharacters = Len(r.Comment.Text)
End Function