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
 
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.
I can't reproduce your problem, so have no way to diagnose it. Can you step through the code using the F8 key and see what exactly happens at this line:
Code:
S2.UsedRange.Copy Destination:=S3.Cells(nxRw, "A")
Also, before doing that add this line:
Code:
On Error GoTo 0
after this line:
Code:
Sheets("TrackerMaster").Delete
 
Last edited:
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I can't reproduce your problem, so have no way to diagnose it. Can you step through the code using the F8 key and see what exactly happens at this line:
Code:
S2.UsedRange.Copy Destination:=S3.Cells(nxRw, "A")
Also, before doing that add this line:
Code:
On Error GoTo 0
after this line:
Code:
Sheets("TrackerMaster").Delete

Hi @JoeMo thanks for providing the fix and sorry for getting back to you late. The macro now copies entries from the "TrackerArchive"; however, it copies everything including the heading (row 1)

I think that this is the code line that needs additional condition:
Code:
S2.UsedRange.Copy Destination:=S3.Cells(nxRw, "A")

May I kindly ask if I could bug you again for a fix?

Thanks
 
Upvote 0
Hi @JoeMo thanks for providing the fix and sorry for getting back to you late. The macro now copies entries from the "TrackerArchive"; however, it copies everything including the heading (row 1)

I think that this is the code line that needs additional condition:
Code:
S2.UsedRange.Copy Destination:=S3.Cells(nxRw, "A")

May I kindly ask if I could bug you again for a fix?

Thanks
Of course it copies everything because your original post said nothing to the contrary. We can't read your mind or see your spreadsheet. You need to specify exactly what you want copied or post your layout so we can see what range or ranges you wish to include in the copy.
 
Upvote 0
Of course it copies everything because your original post said nothing to the contrary. We can't read your mind or see your spreadsheet. You need to specify exactly what you want copied or post your layout so we can see what range or ranges you wish to include in the copy.
@JoeMo I'm sorry for confusing you from the onset. Let me try again. Uhm, I have two worksheets, "TrackerActive" and "TrackerArchive":
  • Both of these worksheets have information from Column A to Column AD
  • Heading of these worksheets are the same - found in Row 1
    • This heading should be the same heading to be copied into "TrackerMaster"
  • Only rows 2 up until the last row with data (for both "TrackerActive" and "TrackerArchive") should then be copied into "TrackerMaster"

Hope this clarifies the matter
 
Last edited:
Upvote 0
Change this line:
Code:
S2.UsedRange.Copy Destination:=S3.Cells(nxRw, "A")
to this:
Code:
S2.UsedRange.Offset(1,0).Copy Destination:=S3.Cells(nxRw, "A")
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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