发布网友
共1个回答
热心网友
Private Sub CommandButton1_Click()
Dim TTT$
TTT = InputBox("● 本程序将设置本工作表批注:" & Chr(13) & Chr(13) _
& " 1、“属性”为:大小固定,位置随单元格而变" & Chr(13) _
& " 2、“对齐”为:自动调整大小" & Chr(13) & Chr(13) _
& "● 选定单一单元格时,处理整个工作表内批注;" & Chr(13) _
& " 选定多个单元格时,处理选定区域内批注。" & Chr(13) _
& Chr(13) & Chr(13) & "是否继续执行?", "提示", "是")
If TTT <> "是" Then Exit Sub
Application.ScreenUpdating = False
On Error GoTo 10
Dim TempRngA As Range
Dim tempRngB As Range
Set TempRngA = Selection
Set tempRngB = ActiveCell
Dim Rng As Range
Application.DisplayCommentIndicator = xlCommentAndIndicator '显示批注和标识符
If Selection.Cells.Count = 1 Then Cells.Select
Selection.SpecialCells(xlCellTypeComments).Select
For Each Rng In Selection
Rng.Activate
ActiveCell.Comment.Shape.Select True
Selection.Placement = xlMove '大小固定,位置随单元格而变
Selection.AutoSize = True '自动调整大小
Next Rng
10 TempRngA.Select
tempRngB.Activate
Set TempRngA = Nothing
Set tempRngB = Nothing
'Application.DisplayCommentIndicator = xlCommentIndicatorOnly '仅显示标识符
Application.ScreenUpdating = True
End Sub