|
Sub 批量排序()
Application.ScreenUpdating = False
Dim folderPath As String
Dim wb As Workbook
folderPath = ThisWorkbook.path ' 请将这里的路径替换为实际工作簿所在的文件夹路径
f = Dir(folderPath & "\*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(folderPath & "\" & f)
With wb.Worksheets(1)
r = .Cells(Rows.Count, 2).End(xlUp).Row
.Range("a2:i" & r).Sort .[i2], 2, , , , , , 1 '第一个数据,表示升序还是降序,1为升序,2为降序,第二个数据表示标题行数
End With
wb.Close True
End If
f = Dir
Loop
Set wb = Nothing
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|