|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub lll() '代码请参考一下
Dim fos As New FileSystemObject
Dim str As String
Dim wj
Dim sht As Worksheet
Dim i As Integer
Dim k As Integer
Dim m As Integer
Dim wb As Workbook
str = "D:\360MoveData\Users\Lenovo\Desktop\新建文件夹\"
For Each wj In fos.GetFolder(str).Files
If wj.Name <> "加序号.xlsx" Then
On Error Resume Next
Set wb = Workbooks.Open(str & wj.Name)
For Each sht In Sheets
i = sht.Cells(Rows.Count, 1).End(xlUp).Row
k = sht.Cells(1, Columns.Count).End(xlToLeft).Column
Cells(1, k + 1) = "序号"
For m = 2 To i
Cells(m, k + 1) = m - 1
Next
Next
wb.Save
wb.Close
End If
Next
End Sub |
|