|
发表于 2014-6-20 19:43
|
显示全部楼层
本楼为最佳答案
- Sub demo1()
- Dim objDic As Object
- Dim strPath$, strFile$, strTemp$
- Set objDic = CreateObject("scripting.dictionary")
- strPath = ThisWorkbook.Path & ""
- strFile = Dir(strPath & "*.xls")
- Do While Len(strFile)
- If strFile <> ThisWorkbook.Name Then
- If strFile Like "*-*-*-*.*" Then
- strTemp = Left(strFile, InStr(strFile, "-") - 1)
- objDic(strTemp) = objDic(strTemp) + 1
- Name strPath & strFile As strPath & strTemp & objDic(strTemp) & Mid(strFile, InStrRev(strFile, "."))
- End If
- End If
- strFile = Dir
- Loop
- Set objDic = Nothing
- End Sub
复制代码 没有测试,另外,如果重复运行,应该会产生错误,而且有BUG。 |
|