PDA

View Full Version : Solved: copy the first row on sheet to lastest blank row of another Sheet .



parscon
04-06-2012, 04:16 AM
I have a VBA code that will copy the latest row of sheet to another blank row on another sheet .



Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).EntireRow.Copy _
Worksheets("Sheet5").Range("A" & Rows.Count).End(xlUp).Offset(1)
Application.CutCopyMode = False

Now i need to copy the first row of Sheet1 to latest blank row of sheet5 .

Thank you for your help .

Bob Phillips
04-06-2012, 04:31 AM
Worksheets("Sheet1").Rows(1).Copy _
Worksheets("Sheet5").Range("A" & Rows.Count).End(xlUp).Offset(1)

parscon
04-06-2012, 04:32 AM
Thank you very much for your great work Xld.

Aussiebear
04-06-2012, 06:42 AM
Worksheets("Sheet1").Rows(1).Copy _
Worksheets("Sheet5").Range("A" & Rows.Count).End(xlUp).Offset(1)

How does Excel know what to do with the copied material?

Bob Phillips
04-06-2012, 06:54 AM
How does Excel know what to do with the copied material?

You seem to have lost an underscore.

Aussiebear
04-07-2012, 02:19 AM
Perhaps I have ( since I copied your code) I not sure where it happened..... but how does that effect the outcome?

Bob Phillips
04-07-2012, 04:27 AM
It changes one meaningful line to two syntactically incorrect lines.

Aussiebear
04-07-2012, 02:41 PM
I understand the purpose of the underscore. I am more interested in the outcome of the two lines of code. Again I ask, How does Excel know what to do with the copied code?

Bob Phillips
04-08-2012, 03:41 AM
It goes to the other range!

Aussiebear
04-08-2012, 03:53 AM
So effectively you need not tell Excel to paste the data. Are there other vba examples where excel knows without it having to be indicated?

Bob Phillips
04-08-2012, 05:30 AM
Copy has a Destination argument, so the paste is implicit.

omp001
04-08-2012, 06:01 AM
... Are there other vba examples where excel knows without it having to be indicated?
[A1].Copy [B1]

Aussiebear
04-08-2012, 02:59 PM
Thank you

Bob Phillips
04-08-2012, 03:35 PM
That is not another one, it is just another way of the same sort of copy paste we were talking about. [...] is a shorthand (and horrible) way of calling Evaluate.