#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Question on Macros

I have a macro that is moving data from on sheet to another.

For example the macro below will move everything that is in l51down to n2.

Sheets("sheet1").Range("l51:l" & Trim(Str(20 + iRows))).Copy
Sheets("sheet3").Range("n2:n" & Trim(Str(3 + iRows))).PasteSpecial
Paste:=xlPasteValues

How can I move more data to sheet 3 that will automatically put the data in
the last row where the previous data was placed?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Question on Macros

I think you mean the first empty row? Either put the data in LastRow or
NewRow.

with Sheets("Sheet3")
LastRow = .Range("n" & Row.Count).end(xlup).row
NewRow = LastRow + 1
Sheets("sheet1").Range("l51:l" & Trim(Str(20 + iRows))).Copy
.Range("n2:n" & NewRow).PasteSpecial
Paste:=xlPasteValues

"Juan Carlos" wrote:

I have a macro that is moving data from on sheet to another.

For example the macro below will move everything that is in l51down to n2.

Sheets("sheet1").Range("l51:l" & Trim(Str(20 + iRows))).Copy
Sheets("sheet3").Range("n2:n" & Trim(Str(3 + iRows))).PasteSpecial
Paste:=xlPasteValues

How can I move more data to sheet 3 that will automatically put the data in
the last row where the previous data was placed?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Question on Macros

Dim DestCell as range

With worksheets("Sheet3")
set destcell = .cells(.rows.count,"N").end(xlup).offset(1,0)
end with

worksheets("sheet1").range("L51:L" & 20 + irows).copy
destcell.pastespecial paste:=xlpastevalues

(VBA is very forgiving. You don't need the trim(str()) stuff.)




Juan Carlos wrote:

I have a macro that is moving data from on sheet to another.

For example the macro below will move everything that is in l51down to n2.

Sheets("sheet1").Range("l51:l" & Trim(Str(20 + iRows))).Copy
Sheets("sheet3").Range("n2:n" & Trim(Str(3 + iRows))).PasteSpecial
Paste:=xlPasteValues

How can I move more data to sheet 3 that will automatically put the data in
the last row where the previous data was placed?

Thanks


--

Dave Peterson
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
Question on Macros in 2007 Vicky Excel Discussion (Misc queries) 4 September 5th 08 08:10 PM
Question about macros. [email protected] Excel Discussion (Misc queries) 3 May 11th 06 09:01 PM
Question about merging macros Greegan Excel Worksheet Functions 2 August 7th 05 11:46 PM
Macros/Signatures Question Curt New Users to Excel 1 June 19th 05 12:39 AM
question macros wnl2007 Excel Worksheet Functions 1 June 10th 05 10:56 PM


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

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"