标签:pen 设置 top use upd this 工作 vba xlsx
Sub 合并工作簿() Dim my_path, my_file As String Dim ws As Worksheet Dim wb As Workbook Dim twb As Workbook Set twb = ThisWorkbook ‘设置twb 为当前代码所在工作簿 my_path = "C:\Users\queqiaoshui\Desktop\excel\" & "*.xlsx" my_file = Dir(my_path) Do While my_file <> "" Set wb = Workbooks.Open("C:\Users\queqiaoshui\Desktop\excel\" & my_file) ‘打开遍历到的工作簿并赋给wb wb.Sheets.Copy , twb.Worksheets(twb.Worksheets.Count) ‘ 把打开的工作簿中的表复制到代码所在工作簿 wb.Close my_file = Dir Application.ScreenUpdating = True Loop End Sub
标签:pen 设置 top use upd this 工作 vba xlsx
原文地址:https://www.cnblogs.com/queqiaoshui/p/10270580.html