Thread: Insert a Range
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen Per Jessen is offline
external usenet poster
 
Posts: 1,533
Default Insert a Range

Hi Steve

Try this, (I assume you want to copy entire row)

Sub test()
Dim LastRange As Range
LastRow = ActiveSheet.Range("D65536").End(xlUp).Row
Set LastRange = ActiveSheet.Rows(LastRow - 8).Resize(9, 1)

LastRange.EntireRow.Copy
LastRange.Insert Shift:=xlDown
End Sub

Regards,

Per
"Steve" skrev i meddelelsen
...
Hello. I am trying to write code that will do an xlendup on a
worksheet to find the last row, and then offset 9 rows up. After I
have the range, copy the range and insert on the next available line.
I tried some code (below) but couldnt get it to work. Any ideas?
Thanks!

lastrow = ActiveSheet.Cells(Cells.Rows.Count, "D").End(xlUp).Row
lastrange = ActiveSheet.Rows(lastrow.Resize(9, 0))

Rows(lastrange).Copy.
Rows(lastrange).Insert Shift:=xlDown