excel多個檔案合併

2022-02-22 11:08:09 字數 1430 閱讀 9517

多個excel檔案合併成乙個需要用ms office wps是不行的

1.將所有檔案放在乙個資料夾裡

2.在資料夾裡新建乙個空的excel開啟

(如果是合併多個sheet的話,右鍵sheet全部選中,點選移動或複製工作表,選擇乙個工作表就o了)

sub 合併當前目錄下所有工作簿的全部工作表()

dim mypath, myname, awbname

dim wb as workbook, wbn as string

dim g as long

dim num as long

dim box as string

mypath = activeworkbook.path

myname = dir(mypath & "\" & "*.xls")

awbname = activeworkbook.name

num = 0

do while myname <> ""

if myname <> awbname then

set wb = workbooks.open(mypath & "\" & myname)

num = num + 1

with workbooks(1).activesheet

if num = 1 then

for g = 1 to sheets.count

wb.sheets(g).usedrange.copy .cells(.range("a65536").end(xlup).row + 1, 1)

next

else

for g = 1 to sheets.count

wb.sheets(g).usedrange.offset(1, 0).copy .cells(.range("a65536").end(xlup).row + 1, 1)

next

end if

wbn = wbn & chr(13) & wb.name

wb.close false

end with

end if

myname = dir

loop

range("a1").select

msgbox "共合併了" & num & "個工作薄下的全部工作表。如下:" & chr(13) & wbn, vbinformation, "提示"

end sub

下面是4個檔案合併的效果圖

合併多個excel檔案方法

本指令碼適用於合併多個excel檔案 同事創作 2018 03 28 zc guo。1.所有需要合併的excel檔案放在同一資料夾內 要求內部結構相同 2.在同一資料夾,建立新的excel檔案 3.開啟新的excel 開發工具 檢視 4.寫入 sub 合併當前目錄下所有工作簿的全部工作表 dim m...

Python 快速合併多個Excel檔案

注意 需要安裝pandas,openpyxl這兩個第三方類庫,否則會報錯。實現 coding gbk import os import pandas as pd dir input 請輸入待合併檔案的路徑 n 設定工作路徑 frames 存放匯入的檔案 for root,dirs,files in ...

多個EXCEL檔案合併成乙個

python的numpy處理起來會比較方便,有空實現一下,這裡是excel內部 的方式 合併方法如下 1.需要把多個excel表都放在同乙個資料夾裡面,並在這個資料夾裡面新建乙個excel。如圖所示 2.用microsoft excel開啟新建的excel表,並右鍵單擊sheet1,找到 檢視 單擊...