Note: The other languages of the website are Google-translated. Back to English
ログイン  \/ 
x
or
x
今すぐ登録  \/ 
x

or

ワークシートまたはワークブックをXNUMXつのワークシートにマージまたは統合するにはどうすればよいですか?

私たちの日常業務では、Excelで[コピーして貼り付け]コマンドを使用すると、データを分析するために数百枚のシートまたはブックをXNUMX枚のシートにマージするという問題が発生する場合があります。 このチュートリアルでは、この仕事をすばやく解決するためのヒントをいくつか紹介します。

ドキュメント結合1

クイックナビゲーション

アクティブなブックのすべてのシートをVBAを使用してXNUMXつのシートにマージする
数十枚のシートまたはワークブックをXNUMXつのワークシート/ワークブックにクリックでマージ
XNUMXつのテーブルをXNUMXつにマージし、クリックで列ごとに更新します
サンプルファイルをダウンロードする


アクティブなブックのすべてのシートをVBAを使用してXNUMXつのシートにマージする

このセクションでは、実行中にアクティブなブックのすべてのシートを収集するための新しいシートを作成するVBAコードを提供します。

1.すべてのシートを結合するワークブックをアクティブにしてからを押します + 開くキー Microsoft Visual Basic for Applications 窓。

2.ポップウィンドウで、をクリックします インセット > モジュール 新しいモジュールスクリプトを作成します。

3.以下のコードをコピーして、スクリプトに貼り付けます。

Sub Combine()
'UpdatebyExtendoffice
Dim J As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Combined"
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For J = 2 To Sheets.Count
Sheets(J).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
Next
End Sub
ドキュメント結合2

4。 押す F5 キーを押すと、シート全体のすべてのデータが、すべてのシートの前面に配置されるCombinedという名前の新しいシートにマージされます。


移動する

あなたは昇給と家族と一緒に多くの時間を過ごしたいですか?

Officeタブは、現在作業中のMicrosoft Officeで効率を50%向上させます

信じられないほど、XNUMXつ以上のドキュメントで作業する方が、XNUMXつで作業するよりも簡単で高速です。

よく知られているブラウザと比較して、Officeタブのタブ付きツールはより強力で効率的です。

毎日何百ものマウスクリックとキーボード入力を減らして、今すぐマウスの手に別れを告げましょう。

通常、複数のドキュメントで作業する場合は、Officeタブを使用すると時間を大幅に節約できます。

30日無料トライアル、クレジットカードは必要ありません。

続きを読む 今すぐダウンロード


数十枚のシートまたはワークブックをXNUMXつのワークシート/ワークブックにクリックでマージ

VBAを使用すると、アクティブなブック内のシートのみを組み合わせることができますが、ブック間でシートをシートまたはブックにマージするにはどうすればよいですか?

ブック全体のシートをXNUMXつのシートにマージします
ドキュメント結合18

ブック全体のシートをXNUMXつのブックにマージします
ドキュメント結合3

この仕事を解決し、シートの組み合わせに関する他の要件を満たすために、 組み合わせる 関数は、次のXNUMXつの組み合わせシナリオで開発されました。

  • 複数のシートまたはワークブックをXNUMXつのシートに結合します
  • 複数のシートまたはワークブックをXNUMXつのワークブックに結合する
  • 同じ名前のシートをXNUMXつのシートに結合します
  • シートまたはワークブック全体の値をXNUMXつのシートに統合します

次に、XNUMX番目のオプションをインスタンスとして使用します。

複数のシートまたはワークブックをXNUMXつのワークブックに結合する

後の 無料インストール Kutools for Excel、以下のようにしてください:

1. Excelをアクティブにして、をクリックします Kutools Plus > 組み合わせる、ダイアログがポップアップ表示され、結合するワークブックを閉じる必要があることを通知します。 クリック OK 続行します。
ドキュメント結合4
ドキュメント結合5

2。 の中に ワークシートを組み合わせるステップ1 ダイアログ、チェック ワークブックの複数のワークシートをXNUMXつのワークブックに結合します オプション。 クリック ウィザードの次のステップに進みます。
ドキュメント結合6

3。 クリック 追加 > フィレット or フォルダ 結合するワークブックをに追加するには ワークブックリスト ペインで、名前をチェックすることにより、どのワークシートを結合するかを指定できます。 ワークシートリスト ペイン。 クリック ウィザードの最後のステップに進みます。
ドキュメント結合7

4.このステップでは、必要に応じて設定を指定します。 次に、をクリックします 終了.
ドキュメント結合8

5.結合されたブックを配置するフォルダーを選択するためのウィンドウがポップアップし、[ セットで€6.
ドキュメント結合9

これで、ワークブックがXNUMXつのワークブックにマージされました。 また、すべてのシートの前面に、Kutools for Excelという名前のマスターシートも作成され、シートに関する情報と各シートのリンクが一覧表示されます。
ドキュメント結合10

デモ:シート/ワークブックをXNUMXつのシートまたはワークブックに結合します

Kutools for Excel:200+便利な便利なツール。Excelの複雑なタスクを数回クリックするだけで簡単に行えます。

今すぐマウスの手と頸椎症に別れを告げる

Kutools for Excelの300の高度なツールは、80%のExcelタスクを数秒で解決し、何千ものマウスクリックからあなたを引き出します。

1500の作業シナリオに簡単に対処でき、ソリューションを探すために時間を無駄にする必要がなく、人生を楽しむための多くの時間があります。

もちろんあなたも含めて、毎日80人以上の非常に効果的な人々の生産性を110000%向上させます。

痛みを伴うフォーミュラやVBAに悩まされることはもうありません。脳を休ませ、楽しい働きをしてください。

フル機能を備えた30日間の無料トライアル、理由なしに30日間の返金。

より良い体はより良い生活を創造します。


XNUMXつのテーブルをXNUMXつにマージし、クリックで列ごとに更新します

XNUMXつのテーブルをXNUMXつにマージし、以下のスクリーンショットに示すように列に基づいてデータを更新する場合は、 テーブルマージ の有用性 Kutools for Excel.
ドキュメント結合11

Kutools for Excel:複雑なタスクをExcelで数回クリックするだけで簡素化する、200を超える便利なExcelアドイン

後の 無料インストール Kutools for Excel、以下のようにしてください:

1。 クリック Kutools Plus > テーブルマージ 有効にする テーブルマージ ウィザードを起動します。
ドキュメント結合12

2.ウィザードのステップ1で、メインテーブルとルックアップテーブルの範囲を個別に選択する必要があります。 次に、をクリックします .
ドキュメント結合13

3.ベースのメインテーブルのデータを更新するキー列をチェックします。 クリック .
ドキュメント結合14

4.次に、ルックアップテーブルに基づいてデータを更新するメインテーブルの列を確認します。 クリック .
ドキュメント結合15

5.ウィザードのステップ4で、ルックアップテーブルからメインテーブルに追加する列を確認します。 クリック .
ドキュメント結合16

6.ウィザードの最後のステップで、必要に応じて設定オプションを指定します。 次に、をクリックします 終了.
ドキュメント結合17

これで、メインテーブルのデータが更新され、ルックアップテーブルに基づいて新しいデータが追加されました。

デモ:シート/ワークブックをXNUMXつのシートまたはワークブックに結合します

Kutools for Excel:200+便利な便利なツール。Excelの複雑なタスクを数回クリックするだけで簡単に行えます。


サンプルファイルのダウンロード

サンプル


推奨される生産性ツール

Officeタブ-MicrosoftOffice2019-2003およびOffice365でのドキュメントのタブブラウジング、編集、管理


オフィスタブ

Excel 2019-2007を高速化するためのプロフェッショナルアドイン、時間タスクを秒に短縮

このアドインには数十の専門家グループが含まれており、300以上のオプションにより、Excelでの日常のタスクのほとんどが自動化され、生産性が少なくとも50%向上します。 ワンクリックオプトンのグループやバッチ変換など。
今こそ、Kutools forExcelでスピードアップするチャンスです!


Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Pete · 9 months ago
    @martinoreilly Just delete "Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select" from the code.

    If you want to merge all rows from all worksheets, just use the code:

    Sub Combine()
    'UpdatebyExtendoffice
    Dim J As Integer
    On Error Resume Next
    Sheets(1).Select
    Worksheets.Add
    Sheets(1).Name = "Combined"
    Sheets(2).Activate
    Range("A1").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A1")
    For J = 2 To Sheets.Count
    Sheets(J).Activate
    Range("A1").Select
    Selection.CurrentRegion.Select
    Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
    Next
    End Sub
  • To post as a guest, your comment is unpublished.
    Sunny · 9 months ago
    @AJIT DIXIT The Combine function of Kutools for Excel can help you to insert sheet name in a new row of each combined range in the combined sheet by checking First row of each range (new row) in Insert worksheet information section in the last step of the Combine.
  • To post as a guest, your comment is unpublished.
    AJIT DIXIT · 9 months ago
    In combining shhets I want to add one extra column in combined sheet as ShhetName
    Can you suggest ?
  • To post as a guest, your comment is unpublished.
    Eben · 10 months ago
    Hi - this function works well except my file has more than 900 sheets, and when I change the maximum number of rows (Loc 16, "A65536") to a higher number, the macro doesn't work. Is there a way to increase the number of rows that can be shown on the combine sheet?
  • To post as a guest, your comment is unpublished.
    Charlotte · 1 years ago
    The VBA code works fine but I want the data to be merged horizontally(side by side).
    Hope you can help.
  • To post as a guest, your comment is unpublished.
    Sunny · 1 years ago
    @HS Hi, HS, you mean to combine same ranges from sheets into one sheet, it that right? If so, this article may help you: https://www.extendoffice.com/documents/excel/2754-excel-combine-ranges-from-different-worksheets-into-one.html#a3
  • To post as a guest, your comment is unpublished.
    Sunny · 1 years ago
    @Daniel Hi, Daniel, I do not understand your question as you describe it not clearly, but if you have the Combine function in Excel, it can solve most of your question about combining sheets.
  • To post as a guest, your comment is unpublished.
    Daniel · 1 years ago
    Hi,


    Great Code and for the most part it works fantastically well.


    Could I suggest creating a written tutorial for each line of code. I'd love to be able to play around with it to suit my Company's needs.

    In the meantime however could you talk me through problems that would hinder this code from copying all data from each Sheet? I've noticed some sheets in my workbook aren't being copied at all.

    To give you some context I'm dealing with roughly 330 sheets and they hold from 50 to 500 lines in each.


    looking forward to hearing from you.
  • To post as a guest, your comment is unpublished.
    HS · 1 years ago
    Hi,

    Is it possible to only copy a particular range of cells for example A:4:FU38 from each sheet?


    Also in the Combined sheet where the data is copied to, can the tab names from where the data is copied included in column A to enable lookups or to pivot the data?


    Finally, can i specify the list of worksheets from which to copy the data across or maybe i can specify something like copy all worksheets to the left of a particular worksheet in the file.


    Thanks in advance for your help
  • To post as a guest, your comment is unpublished.
    Dennis · 1 years ago
    This VBA code is an absolute lifesaver. Thank you!!
  • To post as a guest, your comment is unpublished.
    Sunny · 2 years ago
    @martinoreilly Yes, the code only can keep first row of the first tab, because it is used to consolidate, if you want to keep all contents of each sheet, you can try Combine utility of Kutools for Excel, it is free fior 60 days
  • To post as a guest, your comment is unpublished.
    martinoreilly · 2 years ago
    Hi. This code works well but I have the same problem as adj. The 1st row form each tab doesn't appear in the combined tab - except he first tab. Thanks
  • To post as a guest, your comment is unpublished.
    Sunny · 2 years ago
    @elok Hello, elok, did the problem appear while you applying Combine function? If so, please go to contact us support@extendoffice.com to describe the problem with more details, our support will handle the problem for you.
  • To post as a guest, your comment is unpublished.
    elok · 2 years ago
    i had a problem when I try to combine all same name worksheet to one worksheet, it works but some value are missing. so what should i do?
  • To post as a guest, your comment is unpublished.
    Sunny · 2 years ago
    @thangaraj571@gmail.com Sorry, Thangaraj R, I do not undertsand your problem clearly, could you upload a screenshot to describe your quetion with more detials?
  • To post as a guest, your comment is unpublished.
    Sunny · 2 years ago
    @Andrew Thanks for your support, Andrew, I am glad that the macro can help you.
  • To post as a guest, your comment is unpublished.
    Sunny · 2 years ago
    @Gio Sorry, I do not understand your problem clearly, do you mean to combine sheets with same column header? If so, this article may help you.

    https://www.extendoffice.com/documents/excel/3252-excel-merge-excel-files-same-header.html
  • To post as a guest, your comment is unpublished.
    Andrew · 2 years ago
    Thanks that macro saved my day. I had over 40 sheets of data to combine into one and although my computer bogged for a minute or two, it completed without issue. The only modification I made was I tweaked the macro to start with A2 instead of A1 since A1 was my column headers.
  • To post as a guest, your comment is unpublished.
    thangaraj571@gmail.com · 2 years ago
    hi I would like combine all the worksheets in single sheet where i need data of column A of all worksheets and I need the worksheet names in column B
  • To post as a guest, your comment is unpublished.
    Gio · 2 years ago
    Hi all,
    I need to combine only sheets with identical heading, ship other sheets.


    thanks
  • To post as a guest, your comment is unpublished.
    Sunny · 2 years ago
    @arul.annalect@gmail.com The below code will combine sheets from the second row, you can change the number 2 (xStart = 2) to other number for you need.

    Sub CombineForm()
    Dim xStart, xFNum, xIntCFMax, xIntRRg, xIntCRg As Integer
    Dim xCFWS, xWS As Worksheet
    Dim xObjSR As Range
    Dim xStrName As String
    On Error Resume Next
    Application.ScreenUpdating = False
    xStart = 2
    xStrName = "CombinedForm"
    Set xWS = Sheets(xStrName)
    If xWS Is Nothing Then
    xWS.Delete
    End If
    Set xCFWS = Worksheets.Add
    xCFWS.Name = xStrName

    For xFNum = 1 To Sheets.Count
    Set xWS = Sheets(xFNum)
    If xWS.Name <> xStrName Then
    xWS.Activate
    xIntRRg = xWS.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    xIntCRg = xWS.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
    If xStart <= xIntRRg Then
    Set xObjSR = Range(Cells(xStart, 1), Cells(xIntRRg, xIntCRg))
    xObjSR.Select
    Selection.Copy Destination:=xCFWS.Range("A65536").End(xlUp)(2)
    End If
    End If
    Next
    Application.ScreenUpdating = True
    End Sub
  • To post as a guest, your comment is unpublished.
    arul.annalect@gmail.com · 2 years ago
    @Sunny Thank you, Sunny! This coding is working fine..

    But i want to combine all the sheets from row no: 16. Could you help us to update the coding.

    Thanks
    Arul
  • To post as a guest, your comment is unpublished.
    arul · 2 years ago
    @Sunny Thank you, Sunny!

    I want to combine the sheet from row no:16. Could you help me to update the coding.

    Thanks
    Arul
  • To post as a guest, your comment is unpublished.
    Sunny · 2 years ago
    @arul.annalect@gmail.com You can try below code, it will merge all data and skip blank rows.

    Sub CombineForm()
    Dim xI, xMax As Integer
    Dim xCWS, xWS As Worksheet
    Dim xObjRRange, xObjCRange, xObjSR As Range
    On Error Resume Next
    Sheets(1).Select
    Set xCWS = Worksheets.Add
    xCWS.Name = "Combined"
    Sheets(2).Activate
    Range("A1").EntireRow.Select
    Selection.Copy Destination:=xCWS.Range("A1")
    For xI = 2 To Sheets.Count
    Set xWS = Sheets(xI)
    xWS.Activate
    Set xObjRRange = xWS.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
    Set xObjCRange = xWS.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
    Set xObjSR = Range(Cells(1, 1), Cells(xObjRRange.Row, xObjCRange.Column))
    xObjSR.Select
    Selection.Copy Destination:=xCWS.Range("A65536").End(xlUp)(2)
    Next
    xMax = xCWS.Range("a65536").End(3).Row
    xCWS.Range("a1:a" & xMax).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End Sub
  • To post as a guest, your comment is unpublished.
    arul.annalect@gmail.com · 2 years ago
    @arno Do we have any solution to copy the data below the blank cell?
  • To post as a guest, your comment is unpublished.
    arul.annalect@gmail.com · 2 years ago
    Hi all,

    I have used the below mentioned code, In my data some blank Rows is there for each tab. Data is not coping after the blank rows. How to combine the all data after the blank rows. Please advise.

    Sub Combine()
    Dim J As Integer
    On Error Resume Next
    Sheets(1).Select
    Worksheets.Add
    Sheets(1).Name = "Combined"
    Sheets(2).Activate
    Range("A16").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A1")
    For J = 2 To Sheets.Count
    Sheets(J).Activate
    Range("A17").Select
    Selection.CurrentRegion.Select
    Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
    Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
    Next
    End Sub

    Thanks
    Arul
  • To post as a guest, your comment is unpublished.
    Bruno G. · 3 years ago
    @neno Change all the "A1" in the code to "A26". Save your data before trying this change, just in case!
  • To post as a guest, your comment is unpublished.
    neno · 3 years ago
    My headings start on row 26, the first 25 rows are occupied with the parameters I used to generate my reports, it would take a long time to delete these since there are many reports generated. Using the VBA code above, how could I configure this code to exclude the first 25 rows, capture the headings on row 26 and combine all the data under the headings (row 27 onwards) for each worksheet?
  • To post as a guest, your comment is unpublished.
    Nigah · 3 years ago
    @Tina Just save as the current workbook with a new name and delete other three worksheets which you don't want to combine, now you have only your desired two sheets for VBA code execution.
  • To post as a guest, your comment is unpublished.
    Tina · 3 years ago
    Hi.. The VBA code works fine. Thank you! But can you please help on how I can edit the code so that only 2 sheets will be combined? I have 5 sheets in my workbook but I only need to combine 2 of them.
  • To post as a guest, your comment is unpublished.
    deepak · 3 years ago
    hello everyone

    I want to merged more workbook data in one so give me suggest
  • To post as a guest, your comment is unpublished.
    · 3 years ago
    Hi everyone,

    First of all I have to tell that I have no experience with Macro (VBA Codes). However what I need is related to this. Maybe you guys could help me with it.

    I have a workbook and in this workbook there are 10 worksheets. The first 9 Sheets have the same order of the coloumns of titles and in these columns there are names, dates, percentages of Project Status, comments to Projects etc.. As I said the columns have the same order just the name of the worksheets (for different Teams in the Organisation) are different.

    In Addition to this I have to merge all the worksheets and have them in another sheet which is called "Übersicht" (Overview). However there is a different column in the sheet and it's between "Nr." and "Thema" columns (which are in A1 and A2 in all the 9 Sheets) and this different column called "Kategorie" (in A2 in Übersicht-Overwiev sheet). As this column is between These the order is like this "Nr. (A1), Kategorie (A2) and Thema (A3).....".So this category column (Kategorie) should be empty except this all the Information should be merged into this sheet. And also when there is a Change or update in any worksheet, the Information in "Übersicht" (Overview) sheet needs to update by itself. How can I do this?

    P.S.: Every sheet has different filled rows, some 30, some 13, some 5 etc. And the Teams which are responsible for the Sheets can add or delete some rows (in each row there is different Information for different Projects). This also means the number of rows can increase or decrease.

    I hope I explained it well. Thanks a lot in advance!

    I wish you merry Christmas and a happy new year!

    oduff
  • To post as a guest, your comment is unpublished.
    hk · 3 years ago
    The VBA code works fine but I want the data to be merged horizontally(side by side).
    Hope you can help.
  • To post as a guest, your comment is unpublished.
    Jeanette · 3 years ago
    THANK YOU for the VB Code. Amazing. Worked perfectly. I had 72 worksheets to combine into one. It took a second and it was done. YOU ROCK.
  • To post as a guest, your comment is unpublished.
    Yohani · 3 years ago
    Excellent code! Worked very well!
  • To post as a guest, your comment is unpublished.
    Jonas · 3 years ago
    Hello!
    I need your support. I have three sheets (A, B, C) into a worksheet. the sheet contain information on individuals.
    Sheet A: contains all individuals considered as ID with information (age, education, etc...)
    Sheets B et C: contain some individuals (ID) with information (Organisation, income, etc...)
    So I want to combine B and C to A to get all information from A,B, C together.

    Jonas
  • To post as a guest, your comment is unpublished.
    Jennifer · 3 years ago
    Thank you so very much! The code worked perfectly! I appreciate the instruction so very much!!!
  • To post as a guest, your comment is unpublished.
    Gary · 3 years ago
    Hello, this worked fine at first, but now I see that not all rows from all worksheets are appended into the combined sheet. Please help!
  • To post as a guest, your comment is unpublished.
    Suzana · 3 years ago
    Oh dear! Thank you so MUCH. Worked PERFECTLY with the Code. Had trouble and was thinking how to resolve this and then...just in a second! Thank you a lot. God bless you!
  • To post as a guest, your comment is unpublished.
    adj · 3 years ago
    This code works for the most part - however, the first line of each sheet (except for the first sheet) is not extracted into the combined sheet. Which piece of the code should be modified to ensure extraction of the first line?
  • To post as a guest, your comment is unpublished.
    mario · 3 years ago
    You rock guys!
  • To post as a guest, your comment is unpublished.
    s · 3 years ago
    You guys are the best!!! You totally saved me and I look like a super star
  • To post as a guest, your comment is unpublished.
    Daniel · 3 years ago
    THANK YOU SO MUCH!!!!!
  • To post as a guest, your comment is unpublished.
    Mohd · 3 years ago
    How to merge multiple workbooks with multiple worksheets into one workbook?
  • To post as a guest, your comment is unpublished.
    Mohd · 3 years ago
    [quote name="John"], how to merge multiple workbooks with multiple worksheets into one workbook? appriciate if you could reply.
  • To post as a guest, your comment is unpublished.
    John · 3 years ago
    This is amazing. Thank you so much!
  • To post as a guest, your comment is unpublished.
    Jens · 3 years ago
    When installed, Excel 365 gives a memory error and nothing works.
    I had to uninstall kutools to be able to work again :-(
  • To post as a guest, your comment is unpublished.
    Rich Thorpe · 3 years ago
    Thanks for the help on combining worksheets. Saved me hours of mind numbing work!
  • To post as a guest, your comment is unpublished.
    Ryan · 3 years ago
    how do i get the macro to insert column "a" and paste the name of the workbook the data came from in the added column
  • To post as a guest, your comment is unpublished.
    astu · 3 years ago
    it works so well for my case.
    million thanks for sharing!!!!