Excel: Add comment author using vba

女生的网名这么多〃 提交于 2019-12-02 11:38:17

You can add the logged in user name (with the user name in bold) like so - this example for cell A1:

Sub EasyTest()
Dim shCmt As Comment
On Error Resume Next
Set shCmt = [a1].Comment
On Error GoTo 0
If shCmt Is Nothing Then
Set shCmt = [a1].AddComment
shCmt.Text Text:=Environ$("UserName") & Chr(10) & "TestMe"
shCmt.Shape.TextFrame.Characters(1, Len(Environ$("UserName"))).Font.Bold = True
Else
MsgBox "cell already has a comment"
End If
End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!