电脑教程
位置:首页>> 电脑教程>> office教程>> 在excel用VBA更改批注的作者

在excel用VBA更改批注的作者

  发布时间:2022-05-14 14:44:59 

标签:作者,原作者,名称,批注,Excel函数

在Excel中,当光标移动到包含批注的单元格中时,通常会在状态栏和批注中显示批注者的名称。如果需要将批注者改为其他人,可以用下面的VBA代码。以后再插入新的批注,也将使用新输入的名称。使用前先将代码中的“新作者”和“原作者”按照需要进行替换。

Sub ChangeCommentName()
Dim ws As Worksheet
Dim cmt As Comment
Dim strOld As String
Dim strNew As String
Dim strComment As String
strNew = "新作者"
strOld = "原作者"
Application.UserName = strNew
For Each ws In ActiveWorkbook.Worksheets
For Each cmt In ws.Comments
strComment = Replace(cmt.Text, strOld, strNew)
cmt.Delete
cmt.Parent.AddComment Text:=strComment
Next cmt
Next ws
End Sub

0
投稿

猜你喜欢

手机版 电脑教程 asp之家 www.aspxhome.com