《源代码-如何将多个Excel合并.doc》由会员分享,可在线阅读,更多相关《源代码-如何将多个Excel合并.doc(2页珍藏版)》请在三一文库上搜索。
1、将下面分割线内的的代码拷贝进去,并保存。=我是分割线=Sub sheets2one() 定义对话框变量 Dim cc As FileDialog Set cc = Application.FileDialog(msoFileDialogFilePicker) Dim newwork As Workbook Set newwork = Workbooks.Add With cc If .Show = -1 Then Dim vrtSelectedItem As Variant Dim i As Integer i = 1 For Each vrtSelectedItem In .Selected
2、Items Dim tempwb As Workbook Set tempwb = Workbooks.Open(vrtSelectedItem) tempwb.Worksheets(1).Copy Before:=newwork.Worksheets(i) newwork.Worksheets(i).Name = VBA.Replace(tempwb.Name, .xls, ) tempwb.Close SaveChanges:=False i = i + 1 Next vrtSelectedItem End If End With Set cc = NothingEnd Sub=我是分割线=