ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Last row (https://www.excelbanter.com/excel-programming/320894-copy-last-row.html)

Jan

Copy Last row
 
I'd need to help how to copy last row from a sheet to another


I'm a beginer

Thanks
Jan


Tom Ogilvy

Copy Last row
 
Assume we can determine this from column A

Dim rng as Range
With Worksheets("Sheet1")
set rng = .Cells(rows.count,1),End(xlup)
End With
rng.EntireRow.Copy Destination:= _
worksheets("Sheet2").cells(rows.count,1).End(xlup) (2)

this copies the last row of sheet1 to the next empty row in sheet2

--
Regards,
Tom Ogilvy


"Jan" wrote in message
...
I'd need to help how to copy last row from a sheet to another


I'm a beginer

Thanks
Jan




gocush[_29_]

Copy Last row
 
Tom

The (2) at the end of your code line:
worksheets("Sheet2").cells(rows.count,1).End(xlup) (2)

seems to have the same effects as: .Offset(1,0)
I'm not familiar with your notation. Can you explain?

thanks

"Tom Ogilvy" wrote:

Assume we can determine this from column A

Dim rng as Range
With Worksheets("Sheet1")
set rng = .Cells(rows.count,1),End(xlup)
End With
rng.EntireRow.Copy Destination:= _
worksheets("Sheet2").cells(rows.count,1).End(xlup) (2)

this copies the last row of sheet1 to the next empty row in sheet2

--
Regards,
Tom Ogilvy


"Jan" wrote in message
...
I'd need to help how to copy last row from a sheet to another


I'm a beginer

Thanks
Jan





Tom Ogilvy

Copy Last row
 
Shortcut for Item(2)

? range("A1").Item(2).Address
$A$2

Offset is 0 based, item is 1 based.

--
Regards,
Tom Ogilvy

"gocush" /delete wrote in message
...
Tom

The (2) at the end of your code line:
worksheets("Sheet2").cells(rows.count,1).End(xlup) (2)

seems to have the same effects as: .Offset(1,0)
I'm not familiar with your notation. Can you explain?

thanks

"Tom Ogilvy" wrote:

Assume we can determine this from column A

Dim rng as Range
With Worksheets("Sheet1")
set rng = .Cells(rows.count,1),End(xlup)
End With
rng.EntireRow.Copy Destination:= _
worksheets("Sheet2").cells(rows.count,1).End(xlup) (2)

this copies the last row of sheet1 to the next empty row in sheet2

--
Regards,
Tom Ogilvy


"Jan" wrote in message
...
I'd need to help how to copy last row from a sheet to another


I'm a beginer

Thanks
Jan







gocush[_29_]

Copy Last row
 
with a little experimenting I see that

Range("A1")(2).Select ---will move down (A2)
Selection(2).Select ------- will move down if a single cell or a vert.
range
while
Selection(2).Select -------will move to the right in a horiz range.

these then must be the defaults???



"Tom Ogilvy" wrote:

Shortcut for Item(2)

? range("A1").Item(2).Address
$A$2

Offset is 0 based, item is 1 based.

--
Regards,
Tom Ogilvy

"gocush" /delete wrote in message
...
Tom

The (2) at the end of your code line:
worksheets("Sheet2").cells(rows.count,1).End(xlup) (2)

seems to have the same effects as: .Offset(1,0)
I'm not familiar with your notation. Can you explain?

thanks

"Tom Ogilvy" wrote:

Assume we can determine this from column A

Dim rng as Range
With Worksheets("Sheet1")
set rng = .Cells(rows.count,1),End(xlup)
End With
rng.EntireRow.Copy Destination:= _
worksheets("Sheet2").cells(rows.count,1).End(xlup) (2)

this copies the last row of sheet1 to the next empty row in sheet2

--
Regards,
Tom Ogilvy


"Jan" wrote in message
...
I'd need to help how to copy last row from a sheet to another


I'm a beginer

Thanks
Jan








Tom Ogilvy

Copy Last row
 
It moves within the range

and after it exceeds the range, it mimics the same pattern:

Sub Demo1()
For i = 1 To 10
Debug.Print Range("a2:c3")(i).Address, _
Range("A2:c3").Item(i).Address
Next
End Sub

produces:
$A$2 $A$2
$B$2 $B$2
$C$2 $C$2
$A$3 $A$3
$B$3 $B$3
$C$3 $C$3
$A$4 $A$4
$B$4 $B$4
$C$4 $C$4
$A$5 $A$5

--
Regards,
Tom Ogilvy



"gocush" /delete wrote in message
...
with a little experimenting I see that

Range("A1")(2).Select ---will move down (A2)
Selection(2).Select ------- will move down if a single cell or a

vert.
range
while
Selection(2).Select -------will move to the right in a horiz range.

these then must be the defaults???



"Tom Ogilvy" wrote:

Shortcut for Item(2)

? range("A1").Item(2).Address
$A$2

Offset is 0 based, item is 1 based.

--
Regards,
Tom Ogilvy

"gocush" /delete wrote in message
...
Tom

The (2) at the end of your code line:
worksheets("Sheet2").cells(rows.count,1).End(xlup) (2)

seems to have the same effects as: .Offset(1,0)
I'm not familiar with your notation. Can you explain?

thanks

"Tom Ogilvy" wrote:

Assume we can determine this from column A

Dim rng as Range
With Worksheets("Sheet1")
set rng = .Cells(rows.count,1),End(xlup)
End With
rng.EntireRow.Copy Destination:= _
worksheets("Sheet2").cells(rows.count,1).End(xlup) (2)

this copies the last row of sheet1 to the next empty row in sheet2

--
Regards,
Tom Ogilvy


"Jan" wrote in message
...
I'd need to help how to copy last row from a sheet to another


I'm a beginer

Thanks
Jan











All times are GMT +1. The time now is 05:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com