Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Copy last row from sheet 1 to last row in sheet 2

Hi all,
Can anyone provide some code that will:

1. Copy the last completed row in SHeet 1, and
2. Paste the copied row to the next available blank row in Sheet 2 of the
same workbook?

Many thanks.
--
Carlee
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Copy last row from sheet 1 to last row in sheet 2

One way:

Sub CopyBottomRow()

Sheets("sheet1").Range("a65536").End(xlUp).EntireR ow.Copy _
Sheets("sheet2").Range("a65536").End(xlUp).Offset( 1, 0)

End Sub

Regards

Trevor


"Carlee" wrote in message
...
Hi all,
Can anyone provide some code that will:

1. Copy the last completed row in SHeet 1, and
2. Paste the copied row to the next available blank row in Sheet 2 of the
same workbook?

Many thanks.
--
Carlee



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Copy last row from sheet 1 to last row in sheet 2

I there,
the code you provided works, however, when i use it a second time to copy
and paste a new row of data into sheet 2, my previous rows get over written
with the new data.

Is it possible for the code you provided to paste any new rows to the next
available blank row, there by creating a list of pasted rows over time?
--
Carlee


"Trevor Shuttleworth" wrote:

One way:

Sub CopyBottomRow()

Sheets("sheet1").Range("a65536").End(xlUp).EntireR ow.Copy _
Sheets("sheet2").Range("a65536").End(xlUp).Offset( 1, 0)

End Sub

Regards

Trevor


"Carlee" wrote in message
...
Hi all,
Can anyone provide some code that will:

1. Copy the last completed row in SHeet 1, and
2. Paste the copied row to the next available blank row in Sheet 2 of the
same workbook?

Many thanks.
--
Carlee




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy last row from sheet 1 to last row in sheet 2

Trevor's code assumes that the row to be copied and the row to be pasted can
both be determined by looking at column A.

Can you pick out a column that always has data in it if that row is used? If
yes, then you could modify Trevor's code (or Gord's code) to use that column.

Option Explicit
Sub Testme01()
dim myCol as string
dim RngToCopy as range
dim DestCell as range

'what column can you use--I used X.
myCol = "X"

with worksheets("sheet1")
set rngtocopy = .cells(.rows.count,mycol).end(xlup).entirerow
end with

with worksheets("sheet2")
set destcell = .cells(.rows.count,mycol).end(xlup).offset(1,0) _
.entirerow.cells(1)
end with

rngtocopy.copy _
destination:=destcell

end sub

Carlee wrote:

I there,
the code you provided works, however, when i use it a second time to copy
and paste a new row of data into sheet 2, my previous rows get over written
with the new data.

Is it possible for the code you provided to paste any new rows to the next
available blank row, there by creating a list of pasted rows over time?
--
Carlee

"Trevor Shuttleworth" wrote:

One way:

Sub CopyBottomRow()

Sheets("sheet1").Range("a65536").End(xlUp).EntireR ow.Copy _
Sheets("sheet2").Range("a65536").End(xlUp).Offset( 1, 0)

End Sub

Regards

Trevor


"Carlee" wrote in message
...
Hi all,
Can anyone provide some code that will:

1. Copy the last completed row in SHeet 1, and
2. Paste the copied row to the next available blank row in Sheet 2 of the
same workbook?

Many thanks.
--
Carlee





--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Copy last row from sheet 1 to last row in sheet 2

Sub findbottom_paste()

Set rng1 = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp) _
.EntireRow
Set rng2 = Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
rng1.Copy Destination:=rng2
End Sub


Gord Dibben MS Excel MVP

On Sat, 7 Jul 2007 15:48:00 -0700, Carlee
wrote:

Hi all,
Can anyone provide some code that will:

1. Copy the last completed row in SHeet 1, and
2. Paste the copied row to the next available blank row in Sheet 2 of the
same workbook?

Many thanks.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy rows from one Data sheet to another sheet based on cell conte John McKeon Excel Discussion (Misc queries) 2 May 15th 10 06:49 AM
Auto Copy/autofill Text from sheet to sheet if meets criteria Joyce Excel Discussion (Misc queries) 0 November 20th 08 11:05 PM
how to copy a cell with formula from sheet 1 (data is all vertical) into sheet 2 parag Excel Worksheet Functions 3 June 15th 06 10:29 PM
Copy my active sheet to a new sheet and open with an input form Brad Withrow Excel Programming 0 April 6th 06 03:56 AM
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. RonMc5 Excel Discussion (Misc queries) 9 February 3rd 05 12:51 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"