Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy information from the bottom | Excel Discussion (Misc queries) | |||
Copy and paste from last record at bottom of column | New Users to Excel | |||
Excel cut/Paste Problem: Year changes after data is copy and paste | Excel Discussion (Misc queries) | |||
how to paste data from top to bottom to bottom to top | Excel Discussion (Misc queries) | |||
Macro - copy entire row and paste at bottom of another sheet | Excel Programming |