Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default find last row in another worksheet

Hi everybody,
I need to copy data from one sheet (active sheet) to another, say
"printdata". I need to find the next empty row in column A of "printdata" and
paste the information there. My problem is the active sheet will be changing
all the time but the destination is always the same sheet. How can I refer to
the last row in printdata without leaving the active sheet?
--
gaba :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default find last row in another worksheet

gaba,

This will paste from A1:A20 in the activesheet "printdata" as you specified:

Sub test()
Dim printdata_first_empty_row As Long
Dim paste_range As Range
Dim source_range As Range

printdata_first_empty_row = Worksheets("printdata").Range("A" &
Rows.Count).End(xlUp).Row + 1
Set paste_range = Worksheets("printdata").Range("A" &
printdata_first_empty_row)
Set source_range = ActiveSheet.Range("A1:A20") 'change for your situation
source_range.Copy _
Destination:=paste_range
End Sub

Note that if there's nothing in column A of "printdata" it will actually
determine the first empty row as row 2, so you'd have to error check for
that. And it will also error if A65536 (the last cell in column A) is not
empty.

hth,

Doug

"gaba" wrote in message
...
Hi everybody,
I need to copy data from one sheet (active sheet) to another, say
"printdata". I need to find the next empty row in column A of "printdata"
and
paste the information there. My problem is the active sheet will be
changing
all the time but the destination is always the same sheet. How can I refer
to
the last row in printdata without leaving the active sheet?
--
gaba :)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default find last row in another worksheet

Thanks so much Doug, with little changes it made the trick!

"Doug Glancy" wrote:

gaba,

This will paste from A1:A20 in the activesheet "printdata" as you specified:

Sub test()
Dim printdata_first_empty_row As Long
Dim paste_range As Range
Dim source_range As Range

printdata_first_empty_row = Worksheets("printdata").Range("A" &
Rows.Count).End(xlUp).Row + 1
Set paste_range = Worksheets("printdata").Range("A" &
printdata_first_empty_row)
Set source_range = ActiveSheet.Range("A1:A20") 'change for your situation
source_range.Copy _
Destination:=paste_range
End Sub

Note that if there's nothing in column A of "printdata" it will actually
determine the first empty row as row 2, so you'd have to error check for
that. And it will also error if A65536 (the last cell in column A) is not
empty.

hth,

Doug

"gaba" wrote in message
...
Hi everybody,
I need to copy data from one sheet (active sheet) to another, say
"printdata". I need to find the next empty row in column A of "printdata"
and
paste the information there. My problem is the active sheet will be
changing
all the time but the destination is always the same sheet. How can I refer
to
the last row in printdata without leaving the active sheet?
--
gaba :)




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
how to find and unlink current worksheet from old worksheet kmjmail Excel Discussion (Misc queries) 3 January 12th 09 10:52 PM
Find worksheet LantzK Excel Discussion (Misc queries) 1 May 23rd 08 05:19 PM
Find Max Value in WorkSheet Corey Excel Worksheet Functions 11 January 14th 07 11:00 PM
Find the last used Row on a Worksheet poppy Excel Programming 4 November 25th 04 06:12 AM
find last row on a worksheet tracey Excel Programming 3 February 3rd 04 10:39 PM


All times are GMT +1. The time now is 02:40 AM.

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

About Us

"It's about Microsoft Excel"