解决方案 »
- 请问:什么函数能够取小数点后的位数?
- 请教一个简单的问题,大家来帮帮忙
- 请问怎样让for的循环变量取几个固定的值???
- 难道这个打印问题真的解决不了!!!! 高手快来看!!!
- 请问这么通过日期来访问数据?
- 您好,请赐教:用API怎样读取Static类上面的文本信息?
- 请教,请教,请教,如何动态建立控件?
- 把数据导出到EXCEL时出错,帮我看看,急!
- MSHflexgrid控件問題,泡泡龙过来看看
- 如何取得硬盘的物理序列号
- VB winsock控件 TCP client 接收十六进制数据出现乱码,求解决~
- VB编写的与PLC通信的程序,问题:接受到的信息没法回显到text2,立即窗口temp的值子程序或函数未定义。
Dim fso As FileSystemObject, tFolder As Folder, tFile As File
Dim fName As String
' On Error GoTo hErr
Set fso = New FileSystemObject
Set tFolder = fso.GetFolder(ThisWorkbook.Path) ' 文件夹路径
Application.ScreenUpdating = False
For Each tFile In tFolder.Files
fName = tFile.Name
If Right(fName, 5) = ".xlsx" Then '判断条件
If InStr(fName, "test") > 0 Then '判断条件
Call CopySheets(tFile.Path, fName) '拷贝工作表
End If
End If
Next
Application.ScreenUpdating = True
Set tFile = Nothing
Set tFolder = Nothing
Set fso = Nothing
Exit Sub
'hErr:
' Set tFile = Nothing
' Set tFolder = Nothing
' Set fso = Nothing
' MsgBox "error in union()"
End SubSub CopySheets(ByVal fPath As String, ByVal fName As String)
Dim tWB As Workbook, tWS As Worksheet
' On Error GoTo hErr
Application.ScreenUpdating = False
Set tWB = Workbooks.Open(fPath, True, True)
'循环拷贝工作表,并重命名
For Each tWS In tWB.Worksheets
tWS.Copy After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count).Name = Mid(fName, 1, InStr(fName, ".")) & "_" & tWS.Name
Next
tWB.Close
Application.ScreenUpdating = True
Set tWS = Nothing
Set tWB = Nothing
Exit Sub
'hErr:
' Set tWS = Nothing
' Set tWB = Nothing
' MsgBox "error in copysheets()"
End Sub'--这是宏代码部分(union),功能差不多OK,具体的可能还需要调整
'--文件夹目录:test1.xlsx,test2.xlsx,union.xlsm
2、合并后,就是当前打开的Excel 啊,如果你要另存,就在Uion()中for...next后面加一个 ThisWorkbook.SaveAs “路径"
Application.Visible=False
Application.Visible=False谢谢,赵大牛..