[英]VBA Delete autofiltered rows in linked table
I have a linked table where I want to delete rows based on a date. 我有一个链接表,我想根据日期删除行。 I get it to work out all the way to when I want to delete the rows where i get the error message "Delete method of Range Class failed".
当我要删除出现错误消息“ Range Class的删除方法失败”的行时,我得到了解决。 What can be wrong here in the end?
到底这里有什么问题?
Sheets("TimeSeries").Select
Range("TimeSeries[#Headers]").Select
Selection.AutoFilter
ActiveSheet.ListObjects("TimeSeries").Range.AutoFilter Field:=4, Operator:= _
xlFilterValues, Criteria2:=Array(1, Format(Sheets("Start").Range("C2").Value, "mm/dd/yyyy"))
Range("A1").Select
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.SpecialCells(xlCellTypeVisible).Offset(0, 0).Select
Selection.EntireRow.Delete
Thanks! 谢谢!
Assuming you autofilter statement works correctly, no need to use Select
, try it this way: 假设您的autofilter语句正常工作,无需使用
Select
,请尝试这种方式:
With Sheets("TimeSeries").ListObjects("TimeSeries").Range
.AutoFilter ......
.Offset(1).Delete
.AutoFilter
End With
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.