运行时错误1004'应用程序定义或对象定义错误' – 删除形状

我想删除一定范围内的所有形状。

给我的错误是:如果不相交(范围(sShape.TopLeftCell.Address),myR)是没有那么

具体来说,它说:“sShape.TopLeftCell.Address =”当我hover在vba线上。

我的完整代码如下:

Sub Delete_Arrows_DD() Dim i As Integer Dim t As Range Set t = Cells.Find(What:="Trend", LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False) If ActiveSheet.Name = "SCORECARD" Then i = 4 Do While Cells(i, 2).Value <> "" Call Check_for_Arrow_DD(i, t) i = i + 1 Loop Else i = 2 Do While Cells(i, 2).Value <> "" Call Check_for_Arrow_DD(i, t) i = i + 1 Loop End If End Sub Sub Check_for_Arrow_DD(i As Integer, t As Range) Dim sShape As Shape Dim myR As Range Set myR = Cells(i, t.Column) For Each sShape In ActiveSheet.Shapes If Not Intersect(Range(sShape.TopLeftCell.Address), myR) Is Nothing Then sShape.Delete End If Next End Sub