Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

merge multiple worksheets into a single master worksheet

Posted on 2014-01-16
4
Medium Priority
?
1,274 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 31

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 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

618 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