排序:
Range("A:T").Sort Key1:=Range("P1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
SortMethod:=xlPinYin, DataOption1:=xlSortNormal
复制指定区域到新的xls中:
//设置复制区域
Set rang1 = Range("A1:T1")
Set rang2 = Range(Cells(startline, 1), Cells(i - 1, 20))
Application.Union(rang1, rang2).Copy
//打开workbook
Workbooks.Add
With ActiveWorkbook.ActiveSheet
//指定复制的区域
Application.Union(rang1, rang2).Select
.Paste
//保存文件
.SaveAs filename:=ThisWorkbook.Path + "\" + filename
//关闭文件
Workbooks(filename).Close
End With