标签:selection log ddc shape for 依次 背景 comment blog
‘Comment 对象
‘代表单元格批注
1 Sub 批注添加() 2 With [a1] 3 If .Comment Is Nothing Then 4 .AddComment.Text "123" 5 .Comment.Visible = True ‘批注可见 6 End If 7 End With 8 End Sub
添加批注:Range.AddComment.Text
删除批注:Range.ClearComments
1 Sub 删除批注() 2 For Each Rng In Selection 3 If Not Rng.Comment Is Nothing Then 4 Rng.ClearComments 5 End If 6 Next 7 End Sub
重点来了:
1 Sub 批量添加批注() 2 For Each Rng In Range("a2:a20") 3 Rng.ClearComments ‘不管有没有批注先删了,不然之后在原有的批注上添加批注会出错 4 If Rng >= 90 Then Rng.AddComment.Text "优秀" 5 Next 6 End Sub
1 Sub 批量将批注增加背景图() 2 For Each Rng In Selection 3 paths = ThisWorkbook.Path & "\7pic\" & Rng.Value & ".png" ‘根据选择区域的人名依次匹配对应图片文件夹下的图片 4 Rng.ClearComments 5 Rng.AddComment 6 Rng.Comment.Shape.Height = 50 7 Rng.Comment.Shape.Width = 40 ‘设置批注宽度 8 Rng.Comment.Shape.Fill.UserPicture paths 9 Next 10 End Sub
标签:selection log ddc shape for 依次 背景 comment blog
原文地址:http://www.cnblogs.com/gilgamesh-hjb/p/7497317.html