vba实现文件内容汇总

匿名 (未验证) 提交于 2019-12-02 23:39:01
 1.功能介绍     本功能主要实现将同一个文件夹的相似Excel文件里的内容汇总到同一个EXCEL文件中。  2.代码实现 Sub ボタン3_Click()     Dim dstSheet As Worksheet     Set dstSheet = ThisWorkbook.Worksheets(1)     Const Path As String = "D:\ou\Calibration\Result\"     Dim buf As String     Dim value As String     Dim temp() As String      '入力个所     Const prefix = "result_"     Const center_str = "Yaw"          Const cnsDIR = "\" + prefix + center_str + "*.csv"     buf = Dir(Path & cnsDIR, vbNormal)          Dim i As Long     Do While buf <> ""         i = i + 1         Dim srcBook As Workbook         Set srcBook = Workbooks.Open(Path + buf)         Dim srcSheet As Worksheet         Set srcSheet = srcBook.Worksheets(1)         dstSheet.Cells(10, i).value = srcSheet.Cells(1, 1)         srcBook.Close False         'ファイル名を分割         temp = Split(buf, "_")         value = Mid(temp(1), Len(center_str) + 1, Len(temp(1)) - Len(center_str) - 4)         dstSheet.Cells(9, i).value = value         buf = Dir()             Loop  End Sub
文章来源: https://blog.csdn.net/wangfengfan1/article/details/91397954
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!