The following VBA code can help you to get data from all worksheets of active workbook together into a new single worksheet. At the same time, all of the worksheets must have the same field structure, same column headings and same column order. Please do as follows:
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
Dim J As Integer
On Error Resume Next
Sheets(1).Name = “Combined”
For J = 2 To Sheets.Count
Selection.Offset(1, 0).Resize(Selection.Rows.Count – 1).Select
3. Then press F5 key to run the code, and all the data in the workbook has been merged into a new worksheet named Combined which will add before all worksheets.
1. Your data must start from A1, if not, the code will not take effect.
2. Your data must have the same structure.
3. This code only can combine all worksheets of the active workbook, if you want to merge worksheets from multiple workbooks, this code will not work.