帮我写一个vba,删除第10列图片
时间: 2024-05-25 12:18:33 浏览: 137
Sub DeleteColumn10Image()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Set ws = ActiveSheet '更改为需要操作的工作表
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row '获取最后一行的行数
For i = 1 To lastRow '循环每一行
If Not ws.Cells(i, 10).Value Is Nothing Then '如果第10列不为空
If TypeName(ws.Cells(i, 10)) = "Picture" Then '如果第10列是图片
ws.Cells(i, 10).Delete Shift:=xlToLeft '删除第10列,并且左侧单元格向左移动
End If
End If
Next i
End Sub
相关问题
帮我写一个vba,删除第10列的图片
Sub DeleteColumn10Image()
Dim sh As Worksheet
Dim pic As Picture
Set sh = ActiveSheet
For Each pic In sh.Pictures
If pic.TopLeftCell.Column = 10 Then
pic.Delete
End If
Next pic
End Sub
阅读全文