|
本帖最后由 ≡v≡ 于 2016-9-25 17:43 编辑
将多个工作簿内的工作表全部拆分到一块,但是因为工作表名称都一样,所以得提前更名。找了一下午,找到一个代码,但是只对当工作簿起作用。见下面代码。再附上附件
Sub Rename()
Dim str, Filename, wb, sht, ke, dic, dic2
Dim rng As Range, firstadd, MyFileName
Dim lujing As String
Set dic = CreateObject("Scripting.Dictionary")
lujing = Left(ActiveWorkbook.FullName, InStrRev(ActiveWorkbook.FullName, "\"))
MyFileName = Dir(lujing & "*.xlsx") '这里修改文件类型,03版改为.xls就好了。
Do While MyFileName <> ""
dic(lujing & "\" & MyFileName) = MyFileName
MyFileName = Dir
Loop
For Each ke In dic.keys
Set wb = GetObject(ke)
With wb
For Each sht In .Worksheets
sht.name=.name & sht.name
Next
End With
wb.save
wb.close
set wb=nothing
Next
End Sub
|
评分
-
1
查看全部评分
-
|