PC Review


Reply
Thread Tools Rate Thread

Copy last row from sheet 1 to last row in sheet 2

 
 
=?Utf-8?B?Q2FybGVl?=
Guest
Posts: n/a
 
      7th Jul 2007
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
 
Reply With Quote
 
 
 
 
Trevor Shuttleworth
Guest
Posts: n/a
 
      8th Jul 2007
One way:

Sub CopyBottomRow()

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

End Sub

Regards

Trevor


"Carlee" <(E-Mail Removed)> wrote in message
news:CA35D00F-52EC-441A-B1F3-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?Q2FybGVl?=
Guest
Posts: n/a
 
      8th Jul 2007
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).EntireRow.Copy _
> Sheets("sheet2").Range("a65536").End(xlUp).Offset(1, 0)
>
> End Sub
>
> Regards
>
> Trevor
>
>
> "Carlee" <(E-Mail Removed)> wrote in message
> news:CA35D00F-52EC-441A-B1F3-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      8th Jul 2007
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 <(E-Mail Removed)>
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 With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      8th Jul 2007
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).EntireRow.Copy _
> > Sheets("sheet2").Range("a65536").End(xlUp).Offset(1, 0)
> >
> > End Sub
> >
> > Regards
> >
> > Trevor
> >
> >
> > "Carlee" <(E-Mail Removed)> wrote in message
> > news:CA35D00F-52EC-441A-B1F3-(E-Mail Removed)...
> > > 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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search for values in a sheet and copy found records one after theother in another sheet AndreasHermle Microsoft Excel Programming 12 17th Jun 2011 08:12 PM
Auto copy cell data from source sheet to another wrkbook sheet IVLUTA Microsoft Excel Programming 2 2nd Jun 2009 05:07 PM
Auto Copy/autofill Text from sheet to sheet if meets criteria Joyce Microsoft Excel Misc 0 20th Nov 2008 11:05 PM
Help: auto-copy entire rows from 1 sheet (based on cell criteria) to another sheet. bertbarndoor Microsoft Excel Programming 4 5th Oct 2007 04:00 PM
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. =?Utf-8?B?Um9uTWM1?= Microsoft Excel Misc 9 3rd Feb 2005 12:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:24 AM.