|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
同目录下新建一个“操作”工作簿,运行代码:
Sub gj23w98()
Application.ScreenUpdating = False
p = ThisWorkbook.Path & "\"
f = Dir(p & "*xls")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(p & f)
r = wb.Sheets(1).[a65536].End(3).Row
s = wb.Sheets(1).UsedRange.SpecialCells(xlCellTypeLastCell).Column
wb.Sheets(1).Cells(1, s + 1) = "村组"
wb.Sheets(1).Range(Cells(2, s + 1), Cells(r, s + 1)) = Split(f, ".")(0)
wb.Save
wb.Close
End If
f = Dir
Loop
Application.ScreenUpdating = True
End Sub |
|