PC Review


Reply
Thread Tools Rate Thread

Copying Data between worksheets

 
 
drinese18
Guest
Posts: n/a
 
      14th Feb 2008
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?
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      14th Feb 2008

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)

"drinese18" wrote:

> 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?

 
Reply With Quote
 
drinese18
Guest
Posts: n/a
 
      14th Feb 2008
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?

"Joel" wrote:

>
> 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)
>
> "drinese18" wrote:
>
> > 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?

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      14th Feb 2008
Your dimension statement is wrong. Rows are numbers between 1 and 65536, not
ranges.

Dim sh1LastRow As long, sh2LastRow As long


"drinese18" wrote:

> 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?
>
> "Joel" wrote:
>
> >
> > 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)
> >
> > "drinese18" wrote:
> >
> > > 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?

 
Reply With Quote
 
drinese18
Guest
Posts: n/a
 
      14th Feb 2008
ok so apart from that everything else is ok?

"Joel" wrote:

> Your dimension statement is wrong. Rows are numbers between 1 and 65536, not
> ranges.
>
> Dim sh1LastRow As long, sh2LastRow As long
>
>
> "drinese18" wrote:
>
> > 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?
> >
> > "Joel" wrote:
> >
> > >
> > > 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)
> > >
> > > "drinese18" wrote:
> > >
> > > > 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?

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      14th Feb 2008
Yes

"drinese18" wrote:

> ok so apart from that everything else is ok?
>
> "Joel" wrote:
>
> > Your dimension statement is wrong. Rows are numbers between 1 and 65536, not
> > ranges.
> >
> > Dim sh1LastRow As long, sh2LastRow As long
> >
> >
> > "drinese18" wrote:
> >
> > > 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?
> > >
> > > "Joel" wrote:
> > >
> > > >
> > > > 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)
> > > >
> > > > "drinese18" wrote:
> > > >
> > > > > 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?

 
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
copying data between worksheets SURGEON1971 Microsoft Excel Misc 2 26th Mar 2009 08:50 AM
Copying data across worksheets Maki Microsoft Excel Misc 2 15th Sep 2008 02:40 PM
Copying Data from several Worksheets to One drvortex Microsoft Excel Programming 2 27th Jul 2006 06:43 PM
Copying data across different worksheets Nic M Microsoft Excel Misc 4 8th May 2006 09:30 PM
Copying data between worksheets CMDenton Microsoft Excel Worksheet Functions 1 25th Jun 2003 07:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:50 AM.