怎样使用VBA为公式添加标注?
1、首先在开发工具中打开VBA编辑器

2、在单元格区域当中输入一些内容作为例子

3、在VBA编辑器中插入模块

4、在模块当中输入如下代码,然后运行
Sub 为公式添加标注()
On Error GoTo endd
Set Rng=Selection.Cells.SpecialCells(xlCellTypeFormulas)
For Each cell In Rng
cell.ClearComments
With cell.AddComment
.Text Text:=cell.Formula
With .Shape
.TextFrame.AutoSize=True
.Fill.ForeColor.SchemeColor=44
.AutoShapeType=msoShapePlaque
If Len(cell.Formula) > 50 And Len(cell.Formula) < 100 Then
.Width=300
.Height=32
ElseIf Len(cell.Formula)>=100 And Len(cell.Formula)<150 Then
.Width=300
.Height=48
ElseIf Len(cell.Formula)>=150 And Len(cell.Formula)<300 Then
.Width=300
.Height=95
ElseIf Len(cell.Formula)>=300 And Len(cell.Formula)<1024 Then
.Width=300
.Height=150
End If
.Visible=False
End With
End With
Next cell
endd:
End Sub

5、选中单元格区域A1∶C8,然后利用快捷键Alt+F8调出运行宏窗口,并单击“执行”按钮,所有公式的单元格都已建立批注,其余单元格忽略

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:150
阅读量:158
阅读量:35
阅读量:156
阅读量:74