删除带有形状的行..TopLeftCell错误 [英] Delete row with shapes.. TopLeftCell Error
问题描述
我目前正在为公司中的其他人制作一个excel模板.我需要使用一个按钮删除行.我相信我已经正确地完成了所有操作,但是我一直遇到错误.
I am currently making an excel template for other people in company to use. I need to delete rows with a single button. I believe I've done everything correctly, but I am keep getting an error.
在下面,您可以看到出现错误的代码;
Right below you can see the codes which gives error;
Worksheets("Storyboard").Activate
Worksheets("Storyboard").Unprotect Password:="**$#B'A1313XQ.;**"
satirlar = Baslangic & ":" & Bitis
For i = Baslangic To Bitis
Dim s As Shape
For Each s In Worksheets("Storyboard").Shapes
If Not Intersect(s.TopLeftCell, Range("L" & Baslangic & ":" & "L" & Bitis)) Is Nothing Then
s.Delete
End If
Next s
Next i
Rows(satirlar).Delete Shift:=xlUp
"s.topleftcell"部分一直出现错误.它说应用程序定义的错误或对象定义的错误".
I am keep getting an error on the "s.topleftcell" part. It says that "application-defined or object defined error".
关于此代码;"Baslangic"和"Bitis"已通过表格进行了预定义.
On this code; "Baslangic" and "Bitis" are predefined with a form.
我可以在这里使用任何可能的建议.
I can use any possible advise here..
推荐答案
数据验证(DV)下拉列表是形状,但是DV下拉列表没有 TopLeftCell
属性.您可以做的是改为遍历 DrawingObjects
:
A data validation (DV) dropdown is a shape, but DV dropdowns don't have a TopLeftCell
property. What you can do is loop through the DrawingObjects
instead:
For i = Baslangic To Bitis
Dim s As Object
For Each s In Worksheets("Storyboard").DrawingObjects
If Not Intersect(s.TopLeftCell, Range("L" & Baslangic & ":" & "L" & Bitis)) Is Nothing Then
s.Delete
End If
Next s
Next i
这篇关于删除带有形状的行..TopLeftCell错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!