Home Topics excel How to merge multiple sheets into one in excel

How to merge multiple sheets into one in excel

Jun 19, 2019 pm 02:36 PM
excel

How to merge multiple sheets into one in excel

In order to merge countless excel table files with the same data format into one excel workbook to facilitate subsequent screening, data extraction, analysis, etc.

It needs to be done in two steps:

The first step: merge all excel into one excel; the contents of the multiple tables just now are transformed into the present A table and multiple sheets below.

Step 2: Merge multiple sheets in this excel into one sheet.

Required basic software: excel software with VBA, you can use Microsoft's office that includes VBA, or you can use the professional version of domestic wps.

The specific steps are described below

Merge different tables into one table with many sheets

1. Create a new one Workbook, name it your merged name.

2. Open this workbook.

3. Right-click on any worksheet label under it and select "View Code". (This button of wps is under the development tools)

4. Paste the following code in the open VBA editing window:

Sub Worksheet merge()

Dim FileOpen
Dim X As Integer
Application.ScreenUpdating = False
FileOpen = Application.GetOpenFilename(FileFilter:="Microsoft Excel文件(*.xls),*.xls", MultiSelect:=True, Title:="合并工作薄")
X = 1
While X <= UBound(FileOpen)
Workbooks.Open Filename:=FileOpen(X)
Sheets().Move After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
X = X + 1
Wend
ExitHandler:
Application.ScreenUpdating = True
Exit Sub
errhadler:
MsgBox Err.Description
End Sub
Copy after login

5. Close the VBA editing window.

6. In excel, go to Tools---Macros---Macros, select "Merge Worksheets Between Workbooks", and then "Execute".

7. In the dialog window that opens, select the worksheets you want to merge. If there are many, you can put them in a folder, and then select them all.

8. Wait. . . . OK!

2 Merge many sheets in one sheet into one sheet

1. In a workbook containing multiple sheets (for example, after merging multiple workbooks, n sheets workbook), create a new sheet

2. Right-click on the newly created sheet label and select "View Code" (the button of wps is under the development tools)

3 . Paste the following code in the open VBA editing window:

Sub Merge all worksheets under the current workbook ()

Application.ScreenUpdating = False
For j = 1 To Sheets.Count
If Sheets(j).Name <> ActiveSheet.Name Then
X = Range("A65536").End(xlUp).Row + 1
Sheets(j).UsedRange.Copy Cells(X, 1)
End If
Next
Range("B1").Select
Application.ScreenUpdating = True
MsgBox "当前工作簿下的全部工作表已经合并完毕!", vbInformation, "提示"
End Sub
Copy after login

Run, wait... Merged A prompt will pop up after that.

The above is the detailed content of How to merge multiple sheets into one in excel. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to filter more than 3 keywords at the same time in excel How to filter more than 3 keywords at the same time in excel Mar 21, 2024 pm 03:16 PM

How to filter more than 3 keywords at the same time in excel

What should I do if the frame line disappears when printing in Excel? What should I do if the frame line disappears when printing in Excel? Mar 21, 2024 am 09:50 AM

What should I do if the frame line disappears when printing in Excel?

How to change excel table compatibility mode to normal mode How to change excel table compatibility mode to normal mode Mar 20, 2024 pm 08:01 PM

How to change excel table compatibility mode to normal mode

How to type subscript in excel How to type subscript in excel Mar 20, 2024 am 11:31 AM

How to type subscript in excel

How to set superscript in excel How to set superscript in excel Mar 20, 2024 pm 04:30 PM

How to set superscript in excel

Where to set excel reading mode Where to set excel reading mode Mar 21, 2024 am 08:40 AM

Where to set excel reading mode

How to use the iif function in excel How to use the iif function in excel Mar 20, 2024 pm 06:10 PM

How to use the iif function in excel

How to read excel data in html How to read excel data in html Mar 27, 2024 pm 05:11 PM

How to read excel data in html

See all articles