Solved

merge multiple worksheets into a single master worksheet

Posted on 2014-01-16
4
1,225 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 29

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 50

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

749 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