|
http://club.excelhome.net/thread-1302851-1-1.html
上面这个帖子里的是要把“多个工作簿中的多个工作表重命名,更名为“工作簿名称+原工作表名称“(代码见下)
而我要求的是把多个工作表按次序更名为 ”工作簿名称+1“、”工作簿名称+2“。。。”工作薄名称+N“
怎么修改下面这组代码?
万分感谢!!!
Sub Rename()
Dim str, Filename, wb, sht, ke, dic
Dim rng As Range, firstadd, MyFileName
Dim lujing As String
Set dic = CreateObject("Scripting.Dictionary")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
lujing = Left(ActiveWorkbook.FullName, InStrRev(ActiveWorkbook.FullName, "\"))
MyFileName = Dir(lujing & "*.xls") '这里修改文件类型,03版改为.xls就好了。
Do While MyFileName <> ""
If MyFileName <> ThisWorkbook.Name Then
dic(lujing & MyFileName) = ""
End If
MyFileName = Dir
Loop
For Each ke In dic.keys
Set wb = Workbooks.Open(ke)
With wb
For Each sht In .Worksheets
sht.Name = Left(.Name, Len(.Name) - 4) & sht.Name
Next
End With
wb.Save
wb.Close
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
|
|