4,816
社区成员
发帖
与我相关
我的任务
分享
ExcelSheet.Range("A2:J20").Sort Key1:=Range("J1"), Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
SortMethod:=xlPinYin, DataOption1:=xlSortNormal
On Error GoTo Err_lbl
Set ExcelApp = CreateObject("Excel.Application") '创建EXCEL对象
Set ExcelBook = ExcelApp.Workbooks.Open(strPath)
Set ExcelSheet = ExcelBook.Worksheets(1) '生成凭证后的ID
ExcelSheet.Range("A2:J" & ExcelSheet.[I65536].End(xlUp).Row).Sort Key1:=Range("J2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlPinYin, DataOption1:=xlSortNormal
ExcelBook.SaveAs ("C:\AAAAAAAA.xls")
Err_lbl:
strGroup = Err.Description
ExcelBook.Close (True)
ExcelApp.Quit
Set ExcelBook = Nothing
Set ExcelApp = Nothing
On Error GoTo Err_lbl
Set ExcelApp = CreateObject("Excel.Application") '创建EXCEL对象
Set ExcelBook = ExcelApp.Workbooks.Open(strPath)
Set ExcelSheet = ExcelBook.Worksheets(1) '生成凭证后的ID
ExcelSheet.Range("A2:J" & ExcelSheet.[I65536].End(xlUp).Row).Sort Key1:=Range("J2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
:=xlPinYin, DataOption1:=xlSortNormal
同样是排序
' ExcelBook.SaveAs ("C:\AAAAAAAA.xls")
Err_lbl:
strGroup = Err.Description
ExcelBook.Close (True)
ExcelApp.Quit
Set ExcelBook = Nothing
Set ExcelApp = Nothing