如何将一个文件夹中多个excel名以及excel里头的sheet名合并到新的excel中?

excel

1个回答

写回答

15986078477

2025-10-30 15:20

+ 关注

excel
excel

新建个excel工作簿,然后按下 Alt + F11 打开VBA编辑器,插入一个模块,把下面这段代码粘贴进去,然后保存为 .xlsm 格式(记得和你要处理的文件放在同一个文件夹里哈):

Sub hbhb() Application.ScreenUpdating = False Dim myPath$, myFile$, AK As Workbook, k%, h% myPath = ThisWorkbook.Path & myFile = Dir(myPath & *.xls*) Do While myFile If myFile ThisWorkbook.Name Then Set AK = Workbooks.Open(myPath & myFile) For k = 1 To 3 h = ThisWorkbook.Sheets.Count Windows(myFile).Activate Sheets(Sheet & k).Copy After:=ThisWorkbook.Sheets(h) ThisWorkbook.Activate

举报有用(0分享收藏

Copyright © 2025 IZhiDa.com All Rights Reserved.

知答 版权所有 粤ICP备2023042255号