VBA to combine data from Column A in two sheets into Column A in third sheet

lilvictorian

New Member
Joined
Jan 30, 2013
Messages
8
Hello,

Looking for help and I think this will be a simple one for the forum. I have a file with multiple sheets. Sheet1 and Sheet2 include a list of IDs in Column A (among other columns which are not the same in the sheets). I'd like to consolidate only the list IDs from Sheet1 and Sheet2 (Column A in both sheets) into Sheet5 Column A so that the IDs are stacked with no spaces. All the sheets include a header row. The number of rows in each sheet will vary.

Thank you for your help!

Example:

Sheet1 Column A
Header
1
2
3
4

Sheet2 Column A
Header
8
9
10

Sheet5 Column A
Header
1
2
3
4
8
9
10
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try using
VBA Code:
Option Explicit

Sub MM1()
With Sheets("Sheet1")
.Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row).Copy Sheets("Sheet5").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1)
End With
With Sheets("Sheet2")
.Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row).Copy Sheets("Sheet5").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1)
End With
End Sub
 
Upvote 0
@Michael M - thanks for your quick response! I'm not sure if I'm doing something wrong (a distinct possibility), but I couldn't get that to work, as the output didn't include all of the IDs from Sheet1 and Sheet2.

@alansidman - I appreciate the tip on Power Queries. I've never used them but will check it out.
 
Upvote 0
I should clarify that the columns in Sheet1 and Sheet2 are not identical, but they both do contain the same heading in Column A (the IDs). Column A is the only column I wish to combine into Sheet5.
 
Upvote 0
Sorry, missed a couple of periods...
VBA Code:
Sub MM1()
With Sheets("Sheet1")
.Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Copy Sheets("Sheet5").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1)
End With
With Sheets("Sheet2")
.Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Copy Sheets("Sheet5").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1)
End With
End Sub
 
Upvote 0
Solution
FYI: this does not make a difference in PQ

I should clarify that the columns in Sheet1 and Sheet2 are not identical, but they both do contain the same heading in Column A (the IDs). Column A is the only column I wish to combine into Sheet5.
 
Upvote 0
Sorry, missed a couple of periods...
VBA Code:
Sub MM1()
With Sheets("Sheet1")
.Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Copy Sheets("Sheet5").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1)
End With
With Sheets("Sheet2")
.Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row).Copy Sheets("Sheet5").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1)
End With
End Sub
This works perfectly. Thanks again for a solution and a speedy response. Much appreciated!
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

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