PDA

View Full Version : Solved: Copy all data on Sheet 1 to the latest blank row of sheet 2



parscon
08-15-2012, 08:40 AM
I want copy all data on Sheet 1 to the latest blank filed of sheet 2 .

Could you please help me with VBA code for this subject .

Thank you very much .

CatDaddy
08-15-2012, 08:44 AM
Sheets(1).Range("A1").UsedRange.Copy Destination:=Sheets(2).Range("A" & Sheets(2).Range("A" & Rows.Count).End(xlup).Row + 1)

parscon
08-15-2012, 08:48 AM
Dear CatDaddy

Thank you but it is not work , give me error

Run-Time error '438':

parscon
08-15-2012, 09:07 AM
I found it


'Get last row of data
lastrowSrc = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row

'Get first blank row (last row of data +1)
lastrowDest = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row + 1

'Copy row
Sheets("Sheet1").Range("A1:E" & lastrowSrc).EntireRow.Copy Sheets("Sheet2").Range("A" & lastrowDest)

CatDaddy
08-15-2012, 09:13 AM
Sheets(2).Range("A1").CurrentRegion.Copy Destination:=Sheets(1).Range("A" & Sheets(1).Range("A" & Rows.Count).End(xlUp).Row)

my bad

parscon
08-15-2012, 09:14 AM
Thank you

CatDaddy
08-15-2012, 09:15 AM
no problem my friend

heysus jamal
08-15-2012, 12:27 PM
Very nice!