①批量删除批注
Sub 批量删除批注()
Dim cm As Comment
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
For Each cm In ws.Comments
cm.Delete
Next cm
Next ws
End Sub
②批量删除名称
sub 批量删除名称()
Dim nm As Name
For Each nm In ThisWorkbook.Names
nm.Delete
Next nm
end sub
③批量超链接
Sub 批量删除超链接()
Dim hl As Hyperlink
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
For Each hl In ws.Hyperlinks
hl.Delete
Next hl
Next ws
End Sub
④批量删除自定义图形图像
Sub 批量删除图形图像()
Dim sp As Shape
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
For Each sp In ws.Shapes
sp.Delete
Next sp
Next ws
End Sub
⑤清除条件格式
Sub 批量清除条件格式()
Cells.FormatConditions.Delete
End Sub
以上代码的实现原理:使用vba中的一些对象集合,然后通过遍历所有的对象将之删除。上面的宏会删掉所有当前工作表的所有工作表中的相应对象。当然也可以用activesheet对象来实现活动工作表中的对象。