[英]Run-Time error '1004 - AutoFilter method of Range class failed
I am getting the above error when running the below code. 运行以下代码时出现上述错误。 I am very new to VBA and need some assistance in debugging. 我是VBA的新手,需要调试方面的帮助。
Sub TransferTest1()
Dim INQUIRE As Worksheet
Dim QUOTE As Worksheet
Dim ORDER As Worksheet
Dim YString As String
Dim RecString As String
Set INQUIRE = ActiveWorkbook.Sheets("Inquiries")
Set QUOTE = ActiveWorkbook.Sheets("Quotes")
Set ORDER = ActiveWorkbook.Sheets("Orders")
With INQUIRE.Range("A6:K1200")
.AutoFilter 11, "Y"
.Offset(1).Resize(, 7).Copy QUOTE.Range("A6") ' columns A:G
.AutoFilter
End With
With QUOTE.Range("A6:N1200")
.AutoFilter 14, "Rec'vd"
.Offset(1).Resize(, 7).Copy ORDER.Range("A6") ' columns A:G
.Offset(1).Resize(, 2).Offset(11).Copy ORDER.Range("K6") ' columns L:M
.AutoFilter
End With
End Sub
Thank you for the help in advance! 预先感谢您的帮助!
R. Smithey 史密斯
Precede each call to .AutoFilter
with, 在每次调用.AutoFilter
,
if .parent.autofiltermode then .parent.autofiltermode = false
This will turn off any pre-existing .AutoFilters if they exist and do nothing if they do not exist. 如果存在的话,这将关闭所有现有的.AutoFilters,如果不存在,则不执行任何操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.