#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Macro range

Hi, i need this code to copy rows, but only from A to J (A:J).

Sub copy3()
Dim lastRow As Long
Dim MySheet As String
MySheet = Sheets("Sheet1").Range("M1").Value
lastRow = Worksheets(MySheet).Cells(Worksheets(MySheet).Rows .Count,
"A").End(xlUp).Row
Worksheets("Sheet1").UsedRange.Copy
Worksheets(MySheet).Activate
Range("A" & (lastRow + 1)).Select
ActiveSheet.Paste
Worksheets(MySheet).Range("A" & (lastRow + 1)).PasteSpecial
Application.CutCopyMode = False
Sheets("Sheet1").Activate
Range("A1").Select
End Sub
Can this be done?
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro range

Maybe this

Sub copy3()
Dim lastRow As Long
Dim MySheet As String
MySheet = Sheets("Sheet1").Range("M1").Value
lastRow = Worksheets(MySheet).Cells(Worksheets(MySheet).Rows .Count,
"A").End(xlUp).Row
worksheets("Sheet1").Range("A1:J" & lastRow).Copy
Worksheets(MySheet).Range("A" & (lastRow + 1)).PasteSpecial
Sheets("Sheet1").Activate
Range("A1").Select
End Sub

Mike

"puiuluipui" wrote:

Hi, i need this code to copy rows, but only from A to J (A:J).

Sub copy3()
Dim lastRow As Long
Dim MySheet As String
MySheet = Sheets("Sheet1").Range("M1").Value
lastRow = Worksheets(MySheet).Cells(Worksheets(MySheet).Rows .Count,
"A").End(xlUp).Row
Worksheets("Sheet1").UsedRange.Copy
Worksheets(MySheet).Activate
Range("A" & (lastRow + 1)).Select
ActiveSheet.Paste
Worksheets(MySheet).Range("A" & (lastRow + 1)).PasteSpecial
Application.CutCopyMode = False
Sheets("Sheet1").Activate
Range("A1").Select
End Sub
Can this be done?
Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Macro range

Hi Mike, it's partially working.
The macro copy only from A:J, but first time i run macro, it copy 1 row. The
second time it copy 2 rows. Third time it copy 4 rows. Forth time it copy 8
rows.....
The macro double the rows, every time.
I need the macro to copy all filled rows. My code was doing that. Your code
is good because it select only from column A to J, but the code is not
working as the original one.
Or am i doing something wrong?
Thanks!

"Mike H" wrote:

Maybe this

Sub copy3()
Dim lastRow As Long
Dim MySheet As String
MySheet = Sheets("Sheet1").Range("M1").Value
lastRow = Worksheets(MySheet).Cells(Worksheets(MySheet).Rows .Count,
"A").End(xlUp).Row
worksheets("Sheet1").Range("A1:J" & lastRow).Copy
Worksheets(MySheet).Range("A" & (lastRow + 1)).PasteSpecial
Sheets("Sheet1").Activate
Range("A1").Select
End Sub

Mike

"puiuluipui" wrote:

Hi, i need this code to copy rows, but only from A to J (A:J).

Sub copy3()
Dim lastRow As Long
Dim MySheet As String
MySheet = Sheets("Sheet1").Range("M1").Value
lastRow = Worksheets(MySheet).Cells(Worksheets(MySheet).Rows .Count,
"A").End(xlUp).Row
Worksheets("Sheet1").UsedRange.Copy
Worksheets(MySheet).Activate
Range("A" & (lastRow + 1)).Select
ActiveSheet.Paste
Worksheets(MySheet).Range("A" & (lastRow + 1)).PasteSpecial
Application.CutCopyMode = False
Sheets("Sheet1").Activate
Range("A1").Select
End Sub
Can this be done?
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
Macro range puiuluipui Excel Discussion (Misc queries) 4 April 8th 09 01:52 PM
Macro deletes row in range, macro then skips the row moved up steven.holloway Excel Discussion (Misc queries) 8 June 11th 08 11:40 AM
macro pop-up to set range? NPell Excel Worksheet Functions 0 April 25th 08 03:48 PM
Macro Range mbnspect Excel Discussion (Misc queries) 2 January 17th 08 05:38 AM
Use Range Name in Macro Blue Hornet Excel Worksheet Functions 3 August 13th 05 06:02 PM


All times are GMT +1. The time now is 02:34 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"