Merge 2 Worksheets with Similar Headings into 1 Master File

iAmPatch

Board Regular
Joined
Jan 13, 2015
Messages
86
Hi,

I've been trying to google and search the forum for a VBA code which would enable me to merge two worksheets with similar headings into one consolidated master file. But I can't seem to find the correct one. Can someone please help me?

My two worksheets are currently named as TrackerActive and TrackerArchive; all the information from both sheets should be consolidated / merged into a worksheet named TrackerMaster.

Thanks a lot to those who can help
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You can append to Excel Files to each other using Get&Transform.
Just which version of Excel do you have?
 
Upvote 0
You didn't provide information on the layout you want for the master sheet. Here's some starter code for you that places the active sheet first starting in A1 followed by the archive sheet in col A first empty cell.
Code:
Sub CreateTrackerMaster()
Dim S1 As Worksheet, S2 As Worksheet, S3 As Worksheet, nxRw As Long
Set S1 = Sheets("TrackerActive")
Set S2 = Sheets("TrackerArchive")
On Error Resume Next
With Application
    .DisplayAlerts = False
    .ScreenUpdating = False
End With
Sheets("TrackerMaster").Delete
Application.DisplayAlerts = True
Set S3 = Sheets.Add(before:=S1)
S3.Name = "TrackerMaster"
S1.UsedRange.Copy Destination:=S3.Range("A1")
nxRw = S3.UsedRange.Rows.Count + 1
S2.UsedRange.Copy Destination:=S3.Cells(nxRw, "A")
Application.ScreenUpdating = True
End Sub
 
Upvote 0
You didn't provide information on the layout you want for the master sheet. Here's some starter code for you that places the active sheet first starting in A1 followed by the archive sheet in col A first empty cell.
Code:
Sub CreateTrackerMaster()
Dim S1 As Worksheet, S2 As Worksheet, S3 As Worksheet, nxRw As Long
Set S1 = Sheets("TrackerActive")
Set S2 = Sheets("TrackerArchive")
On Error Resume Next
With Application
    .DisplayAlerts = False
    .ScreenUpdating = False
End With
Sheets("TrackerMaster").Delete
Application.DisplayAlerts = True
Set S3 = Sheets.Add(before:=S1)
S3.Name = "TrackerMaster"
S1.UsedRange.Copy Destination:=S3.Range("A1")
nxRw = S3.UsedRange.Rows.Count + 1
S2.UsedRange.Copy Destination:=S3.Cells(nxRw, "A")
Application.ScreenUpdating = True
End Sub


Thanks Joe. I'm sorry for not providing additional information. The TrackerMaster should be formatted as "Table" as there will be a need to add-in formulas once the merge / consolidation is finished.
 
Upvote 0
@JoeMo when I tried to run your code; it only copied information from the TrackerActive worksheet :(

It wasn't able to copy the information from TrackerArchive. Is it because TrackerArchive has row headings?
 
Upvote 0
Get&Transform? I'm currently using Excel 2016
Get &Transform was integrated in 2016. Previously known as Power Query.
It provides very much improved data import and manipulation from other sources, including Tables, other workbooks, text files and databases.
Mike Girvin, ExcelIsFun, has an on going series on the subject.
[h=1]<yt-formatted-string class="style-scope ytd-video-primary-info-renderer" style="--yt-endpoint-color:hsl(206.1, 79.3%, 52.7%);">Microsoft Power Tools for Data Analysis: Dashboards & Reports</yt-formatted-string>[/h]Bill, Mr Excel, has been impressed too. https://www.mrexcel.com/news/learn-power-query-this-year/
 
Upvote 0
@JoeMo when I tried to run your code; it only copied information from the TrackerActive worksheet :(

It wasn't able to copy the information from TrackerArchive. Is it because TrackerArchive has row headings?
Can you explain what "wasn't able to copy the information from TrackerArchive" means? Did you get an error message? If so, what was it and what line was highlighted? If not, what exactly happens when you run the code? Is it possible the name of the archive sheet has an unwanted space at the start or end?
 
Upvote 0
Can you explain what "wasn't able to copy the information from TrackerArchive" means? Did you get an error message? If so, what was it and what line was highlighted? If not, what exactly happens when you run the code? Is it possible the name of the archive sheet has an unwanted space at the start or end?

TrackerActive has around 650 rows of data while TrackerArchive has about 4350 rows of data. The macro did not return any error at all. But the result file in TrackerMaster only has the 650 rows from TrackerActive and wasn't able to get the 4350 rows of data from TrackerArchive. There were no spaces in the names of the worksheets and even in the macro line.
 
Upvote 0

Get &Transform was integrated in 2016. Previously known as Power Query.
It provides very much improved data import and manipulation from other sources, including Tables, other workbooks, text files and databases.
Mike Girvin, ExcelIsFun, has an on going series on the subject.
[h=1]<yt-formatted-string class="style-scope ytd-video-primary-info-renderer" style="--yt-endpoint-color:hsl(206.1, 79.3%, 52.7%);">Microsoft Power Tools for Data Analysis: Dashboards & Reports</yt-formatted-string>[/h]Bill, Mr Excel, has been impressed too. https://www.mrexcel.com/news/learn-power-query-this-year/

I have to check on this thoroughly. I can't seem to find that option :( even when trying to check the advanced settings of Excel
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top