![]() |
Copy and Paste to Bottom Row?
I am using the following code to select the last row of a data table.
Set last = LastCell(Sheet2) Cells(last.Row,"A").Select What line would I need to use to copy the contents of cells from ro A2:AA2 on Sheet3 (Sheet 3) to the last row? The "LastCell" statement is a bit of written code used to find the las row:- Function LastCell(ws As Worksheet) As Range Dim LastRow&, LastCol% ' Error-handling is here in case there is not any ' data in the worksheet On Error Resume Next Any ideas?? Thanks Andi With ws ' Find the last real row LastRow& = .Cells.Find(What:="*", _ SearchDirection:=xlPrevious, _ SearchOrder:=xlByRows).Row ' Find the last real column LastCol% = .Cells.Find(What:="*", _ SearchDirection:=xlPrevious, _ SearchOrder:=xlByColumns).Column End With ' Finally, initialize a Range object variable for ' the last populated row. Set LastCell = ws.Cells(LastRow&, LastCol%) End Function :) : -- Message posted from http://www.ExcelForum.com |
Copy and Paste to Bottom Row?
Sub CopyRow()
Dim rng as Range set rng = LastCell(worksheets("Sheet2") Worksheets("Sheet3").Range("A2:AA2").copy _ Destination:=rng.offset(1,0) End Sub Function LastCell(ws As Worksheet) As Range Dim LastRow&, LastCol% With ws ' Find the last real row LastRow& = .Cells.Find(What:="*", _ SearchDirection:=xlPrevious, _ SearchOrder:=xlByRows).Row ' Find the last real column LastCol% = .Cells.Find(What:="*", _ SearchDirection:=xlPrevious, _ SearchOrder:=xlByColumns).Column End With ' Finally, initialize a Range object variable for ' the last populated row. Set LastCell = ws.Cells(LastRow&, LastCol%) End Function "andibevan " wrote in message ... I am using the following code to select the last row of a data table. Set last = LastCell(Sheet2) Cells(last.Row,"A").Select What line would I need to use to copy the contents of cells from row A2:AA2 on Sheet3 (Sheet 3) to the last row? The "LastCell" statement is a bit of written code used to find the last row:- Function LastCell(ws As Worksheet) As Range Dim LastRow&, LastCol% ' Error-handling is here in case there is not any ' data in the worksheet On Error Resume Next Any ideas?? Thanks Andi With ws ' Find the last real row LastRow& = .Cells.Find(What:="*", _ SearchDirection:=xlPrevious, _ SearchOrder:=xlByRows).Row ' Find the last real column LastCol% = .Cells.Find(What:="*", _ SearchDirection:=xlPrevious, _ SearchOrder:=xlByColumns).Column End With ' Finally, initialize a Range object variable for ' the last populated row. Set LastCell = ws.Cells(LastRow&, LastCol%) End Function :) :) --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 02:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com