Copying Data between worksheets

D

drinese18

Does anyone know how to copy data from the last line of data in one worksheet
to the last line in the other worksheet. Basically I want to have a macro
that updates a worksheet on a daily basis. It would copy the last line of
data from Sheet 1 onto the last line in Sheet 2. Does anyone know of a way to
do so this or code maybe?
 
J

Joel

sh1LastRow = sheets("Sheet1").range("A" & rows.count).end(xlup).row

sh2LastRow = sheets("Sheet2").range("A" & rows.count).end(xlup).row

sheets("Sheet1").rows(sh1LastRow).copy _
destination:=sheets("Sheet2").rows(sh2LastRow + 1)
 
D

drinese18

Ok, should the code look somewhat like this?

Sub CopyData()

Dim sh1LastRow As Range, sh2LastRow As Range

sh1LastRow = sheets("Sheet1").range("A" &
rows.count).end(xlup).row

sh2LastRow = sheets("Sheet2").range("A" &
rows.count).end(xlup).row

sheets("Sheet1").rows(sh1LastRow).copy _
destination:=sheets("Sheet2").rows(sh2LastRow + 1)
End Sub

am I missing anything?
 
J

Joel

Your dimension statement is wrong. Rows are numbers between 1 and 65536, not
ranges.

Dim sh1LastRow As long, sh2LastRow As long
 
D

drinese18

ok so apart from that everything else is ok?

Joel said:
Your dimension statement is wrong. Rows are numbers between 1 and 65536, not
ranges.

Dim sh1LastRow As long, sh2LastRow As long
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top