Combine two columns into one from two sheets

Closed
roy76 Posts 1 Registration date Saturday 26 February 2011 Status Member Last seen 26 February 2011 - 26 Feb 2011 à 18:21
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 27 Feb 2011 à 17:33
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)




Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 766
27 Feb 2011 à 17:33
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)