我正在尝试删除某个范围内的所有形状。
给我错误的行是: 如果不相交(范围(sShape.TopLeftCell.Address),myR)则没有那么
具体来说,它说: " sShape.TopLeftCell.Address =" 当我将鼠标悬停在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