我试图调试一些旧代码(不是由我写的),我得到以下运行时错误(1004)第一次AdvancedFilter方法在下面的代码中。Excel VBA - 提取范围丢失或Range.AdvancedFilter上的非法错误
提取区域具有丢失或非法的字段名称
Application.Goto Reference:="first_line"
'Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "data"
Application.Goto Reference:="heading"
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "base"
Application.Goto Reference:="col_last"
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = "test_last"
Sheets("work").Visible = True
Application.Goto Reference:="base"
Range("base").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range(_
"CsummaryA"), CopyToRange:=Range("SsummaryA"), Unique:=False
' error actually happens at this line, not the previous one as I stated previously
Application.Goto Reference:="base"
Range("base").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range(_
"Csummary"), CopyToRange:=Range("Ssummary"), Unique:=True
上什么可能会导致错误的任何想法?
被复制的范围是否有空标题? – JNevill
这两个区域中的标题看起来不错,但感谢您指出了这一点。 – warsong