我需要一键删除Excel中的列和图像。我有宏允许我删除图像,但它不会删除列。
Sub RemoveDrawingObjects()
'Removes any drawing / chart / shapes / ocx control objects from the active worksheet.
Dim iCount As Integer
Dim Embedded_Objects As Integer
Embedded_Objects = ActiveSheet.Shapes.Count
For iCount = Embedded_Objects To 1 Step -1
ActiveSheet.Shapes(iCount).Delete
Next iCount
End Sub
这是我用来删除图像的代码,它工作得很好,如何删除突出显示的列。
欢迎任何建议或提示。
我的提示是删除图片,然后只删除列,但他们只想一次点击它。
答案 0 :(得分:1)
如果已经选择了列,则:
Sub RemoveDrawingObjects()
'Removes any drawing / chart / shapes / ocx control objects from the active worksheet.
Dim iCount As Integer
Dim Embedded_Objects As Integer
Embedded_Objects = ActiveSheet.Shapes.Count
For iCount = Embedded_Objects To 1 Step -1
ActiveSheet.Shapes(iCount).Delete
Next iCount
'delete active column
ActiveCell.EntireColumn.Delete
End Sub
另外,删除所有形状的更简单方法是:
Sub RemoveDrawingObjects()
'Removes any drawing / chart / shapes / ocx control objects from the active worksheet.
Dim shp_fordelete As Shape
For Each shp_fordelete In ActiveSheet.Shapes
shp_fordelete.Delete
Next shp_fordelete
'delete active column
ActiveCell.EntireColumn.Delete
End Sub