View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Copy and Paste LAST ROW of data non-contiguous

Sub CopyLast()
Dim LRow As Long
Dim sh As Worksheet

For Each sh In Worksheets(Array("sheet1", "sheet3", "sheet5"))
LRow = sh.Cells(Rows.Count, "A").End(xlUp).Row
sh.Rows(LRow).Copy Destination:=sh.Rows(LRow + 1)
Next sh
End Sub


"Sam via OfficeKB.com" wrote:

Hi Joel,

Thank you for reply.

I actually need the last row of each sheet in the array to be copied to its
own sheet (the same sheet) but to the next empty row below.

Further help appreciated.

Cheers,
Sam

Joel wrote:
What this code will do is copy the last row of sheet2 to the bottom of all
the sheets listed in the Array in the code below. Array can be in any order
and contain as many sheets as necessary (except sheet 2 cannot be in the
arrray).
Dim LRow As Long
Dim sh as worksheet


with sheets("Sheet2")
Sh2LRow = .Cells(Rows.Count, "A").End(xlUp).Row
end with
for each sh in worksheets(Array("sheet1", "sheet3", "sheet5"))
shLRow = sh.Cells(Rows.Count, "A").End(xlUp).Row
with sheets("Sheet2")
.Rows(Sh2LRow).Copy Destination:=sh.Rows(shLRow + 1)
end with
Next sh
End Sub


--
Message posted via http://www.officekb.com