View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Copy and Paste LAST ROW of data

Sub CopyLast()
Dim r1 as Range, r2 as Range
set r1 = cells(rows.count,1).End(xlup)
if isempty(r1(1,2)) then
set r2 = r1
else
set r2 = r1.end(xltoRight)
end if
Range(r1,r2).Copy r1(2)
End Sub

--
Regards,
Tom Ogilvy


"Sam via OfficeKB.com" wrote:

Hi Mike,

Thanks for reply and assistance.

Does your solution take into account Gary's Student Post:

If A13 and B13 have values, C13 is empty, and D13 has a value,
then
do you want A13 thru B13 or A13 thru D13?


I would like A13 thru B13

Mike Fogleman wrote:
Is there other data surrounding this contiguous data that we need to avoid?
If not, then this simple code will do it:


Sub test()
Dim LRow As Long

LRow = Cells(Rows.Count, 1).End(xlUp).Row
Rows(LRow).Copy Rows(LRow + 1)
End Sub

Mike F


Mike, will this code work with my request for A13 thru B13 based on above,
selecting only contiguous data filled cells on that row?

Please advise.

Cheers,
Sam

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