Macro range

P

puiuluipui

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!
 
M

Mike H

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
 
P

puiuluipui

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top