Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
Copy information from the bottom thebaldsoprano Excel Discussion (Misc queries) 2 January 15th 07 06:23 PM
Copy and paste from last record at bottom of column [email protected] New Users to Excel 0 February 7th 06 10:25 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
how to paste data from top to bottom to bottom to top Dave Peterson Excel Discussion (Misc queries) 0 January 25th 05 12:12 AM
Macro - copy entire row and paste at bottom of another sheet miker1999 Excel Programming 4 January 31st 04 05:28 PM


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