2013-08-29 49 views
0

我需要在Excel中刪除列和圖像,只需點擊一下即可。我有宏允許我刪除圖像,但它不刪除列。從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 

這是我用來刪除圖像的代碼,它工作的很好,我怎麼會刪除突出顯示的列。

歡迎任何建議或提示。

我的提示是刪除圖像,然後只刪除列,但他們想要點擊一下。

+1

http://stackoverflow.com/questions/5991007/excel -deleting圖像-時,刪除一個排 –

回答

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