2017年最后一個工作日下午,同桌扔來一個Excel工作簿,類似如下,需要將右側(cè)單元格中的內(nèi)容批量寫入左側(cè)單元格的批注中。
寫了幾行VBA可以快速實現(xiàn),效果如下
稍微美化了下批注形狀為iPhone圓
VBA代碼如下,如有需要的讀者可以試試。
Sub 批注()
Dim cell As Range
For Each cell In Selection
cell.AddComment
cell.Comment.Text Text:=cell.Offset(0, 1).Value
With cell.Comment
.Visible = True
.Shape.Select True
Selection.ShapeRange.AutoShapeType = msoShapeRoundedRectangle
.Visible = False
End With
Next cell
End Sub
以下是示例文件,宏已內(nèi)置,可直接使用
鏈接: https://pan.baidu.com/s/1i5itNqX 密碼: ncvh