我有一个可以在Excel 2013中运行的宏,但是在Excel 2003中运行该宏时,以下部分代码会中断:
Sheets("dados").Select
Range("A1").AutoFilter Field:=6, Criteria1:="<>"
ActiveSheet.AutoFilter.Sort.SortFields.Clear
ActiveSheet.AutoFilter.Sort.SortFields.Add Key:=Range("A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveSheet.AutoFilter.Sort.Apply
我无法找到其中断的明确原因。我读到有人提到问题是Sort对象,但是没有找到任何替换选项。是否有替代方法可以在Excel 2003中使用呢?
感谢您的帮助。
试试这个:
With ThisWorkbook.Sheets("dados")
.Range("A1").AutoFilter Field:=6, Criteria1:="<>"
.Range("A1").CurrentRegion.Sort Key1:=.Range("A1"), Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, DataOption1:=xlSortNormal
End With
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句