Solved

merge multiple worksheets into a single master worksheet

Posted on 2014-01-16
4
1,245 Views
Last Modified: 2014-01-16
Dear Experts:

below code merges all of the worksheets of the currently active Workbook into a master worksheet named 'Combined'.

Could somebody help me tweak this code with the following requirements.

1.
All of the worksheets to be copied into the 'combined worksheets' have a column header that spans three rows (therefore the '.Offset(3, 0)' in line 15). The Combined Sheet should have this column header at the very top, i.e a column header that spans three rows. With the current code it is just a one row column header.

2.
All of the sheets are to be combined in this master worksheet named 'Combined' with the exception of sheets named 'Evaluation', 'Evaluation Master' and 'Result'

3.
The selected rows/cells in all of the sheets are to be deselected.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas

Sub Merge_multiple_worksheets()
'Merging multiple worksheets into a master worksheet
Dim J As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Combined"
Sheets(2).Activate
Range("A1:A3").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(3, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
Next
End Sub

Open in new window

0
Comment
Question by:AndreasHermle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 30

Expert Comment

by:gowflow
ID: 39785575
Can you post the workbook ?
gowflow
0
 

Author Comment

by:AndreasHermle
ID: 39785613
Hi gowflow,

here we are. Thank you

Regards, Andreas

Worksheet-Combining.xlsm
0
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39785655
Hi,

pls try

Sub Merge_multiple_worksheets()
'Merging multiple worksheets into a master worksheet
Dim J As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Combined"
Sheets(2).Activate
Range("A1:A3").EntireRow.Copy Destination:=Sheets(1).Range("A1")
Sheets(1).Range("A3").Value = " "
Sheets(2).Columns("A:K").Copy
Sheets(1).Columns("A:K").PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
For J = 2 To Sheets.Count
    Sheets(J).Activate
    If ActiveSheet.Name = "Evaluation" Or _
        ActiveSheet.Name = "Evaluation_Master" Or ActiveSheet.Name = "Result" Then
    Else
        Set myRangeTmp = Range("A1").CurrentRegion
        Set myRange = myRangeTmp.Offset(3, 0).Resize(myRangeTmp.Rows.Count - 1)
        a = Sheets(1).Range("A65536").End(xlUp).Row
        myRange.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
    End If
Next
Sheets(1).Activate
Range("A1").Select
End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:AndreasHermle
ID: 39786567
Hi Rgonzo,

this did the trick. Great, thank you very much for your great help.

Regards, Andreas
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question