標題:
[發問]
關於此程式碼再排序指令的優化?
[打印本頁]
作者:
starry1314
時間:
2015-7-7 16:46
標題:
關於此程式碼再排序指令的優化?
請問此段可怎麼優化呢?
有查到關於這小段的說明 好像都是屬於排序? (在最下方圖片)
主要是想要依M列從m2開始 由小到大排序
ActiveWorkbook.Worksheets("工作表1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("工作表1").AutoFilter.Sort.SortFields.Add Key:=Range( _
"M:M"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("工作表1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
複製代碼
完整程式碼
Sub 配膳清單()
'
With Sheets("工作表1")
ActiveSheet.Range("$A$1").AutoFilter Field:=15, Criteria1:=Array( _
"元氣主食", "湯品", "飲品", "點心", "特殊飲品"), Operator:=xlFilterValues
ActiveSheet.Range("$A$1:$AT$96").AutoFilter Field:=19, Criteria1:="."
ActiveWorkbook.Worksheets("工作表1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("工作表1").AutoFilter.Sort.SortFields.Add Key:=Range( _
"M:M"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("工作表1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
.UsedRange.Columns("M:M").Copy Sheets("配膳(早)").[C6]
.UsedRange.Columns("O:O").Copy Sheets("配膳(早)").[A6]
.UsedRange.Columns("Q:Q").Copy Sheets("配膳(早)").[D6]
.Range("A1").AutoFilter
End With
End Sub
複製代碼
[attach]21337[/attach]
作者:
starry1314
時間:
2015-7-7 17:02
回復
1#
starry1314
已解決
Sub 配膳清單()
With Sheets("工作表1")
ActiveSheet.Range("$A$1").AutoFilter Field:=15, Criteria1:=Array( _
"元氣主食", "湯品", "飲品", "點心", "特殊飲品"), Operator:=xlFilterValues
ActiveSheet.Range("$A$1").AutoFilter Field:=19, Criteria1:="."
Range("a2:AW" & [a65536].End(xlUp).Row).Sort Key1:=Range("m2"), Order1:=xlAscending
.UsedRange.Columns("M:M").Copy Sheets("配膳(早)").[C6]
.UsedRange.Columns("O:O").Copy Sheets("配膳(早)").[A6]
.UsedRange.Columns("Q:Q").Copy Sheets("配膳(早)").[D6]
.Range("A1").AutoFilter
En
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)