Combine two columns into one from two sheets

Closed
roy76 Posts 1 Registration date Saturday February 26, 2011 Status Member Last seen February 26, 2011 - Feb 26, 2011 at 06:21 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Feb 27, 2011 at 05:33 PM
Hello,

I have searched and tried some similar examples but cannot find a fit that works .I trying to combine two sheets into one .can someone please help me to modify the code

I want to do the following

sheet 1
date name amount
01/01/11 x 100


sheet2
date name amount
01/02/11 y 200


sheet3 (output sheet)

date name amount
01/02/11 x 100
01/02/11 y 200

Dim lastrowA As Long
Dim lastrowB As Long
Set srcsht = Sheets("sheet1")
Set dstsht = Sheets("sheet2")
lastrowA = srcsht.Cells(Cells.Rows.Count, "A").End(xlUp).Row
lastrowB = dstsht.Cells(Cells.Rows.Count, "A").End(xlUp).Row + 1
srcsht.Range("a1:a" & lastrowA).EntireRow.copy dstsht.Cells(lastrowB, 1)




1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Feb 27, 2011 at 05:33 PM
In your code, the data is copied from sheet1 to sheet2. you modify the code to data to first copy from sheet 1 to sheet 3 and then sheet 2 to sheet 3


Dim lastrowA As Long
Dim lastrowB As Long
Set srcsht = Sheets("sheet1")
Set dstsht = Sheets("sheet3")
lastrowA = srcsht.Cells(Cells.Rows.Count, "A").End(xlUp).Row
lastrowB = dstsht.Cells(Cells.Rows.Count, "A").End(xlUp).Row + 1
srcsht.Range("a1:a" & lastrowA).EntireRow.copy dstsht.Cells(lastrowB, 1)

Set srcsht = Sheets("sheet2")
lastrowA = srcsht.Cells(Cells.Rows.Count, "A").End(xlUp).Row
lastrowB = dstsht.Cells(Cells.Rows.Count, "A").End(xlUp).Row + 1
srcsht.Range("a1:a" & lastrowA).EntireRow.copy dstsht.Cells(lastrowB, 1)
0