cpy last 7 rows of data

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,604
Office Version
  1. 365
Platform
  1. Windows
Hi all

In sheet 1..find last popoulated row in column AL, copy up 7rows of data then paste into sheet2 AH8:AH14

any ideas

thanks so much
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try

Code:
Sheets("Sheet1").Range("AL" & Rows.Count).End(xlUp).Offset(-6).Resize(7).Copy Destination:=Sheets("Sheet2").Range("AH8")
 
Upvote 0
played around with some other vb and kinda got this to work
Code:
Sub Anthony()


Sheets("sheet1").Select

    Range("AL65536").End(xlUp).Offset(-7).Select
    Selection.Resize(Selection.Rows.Count + 7).Select
    Selection.Copy
    Sheets("sheet2").Select
    Range("AH8").Select
    Selection.PasteSpecial Paste:=xlValues
End Sub

thanks though :)
 
Upvote 0
played around with some other vb and kinda got this to work
Code:
Sub Anthony()


Sheets("sheet1").Select

    Range("AL65536").End(xlUp).Offset(-7).Select
    Selection.Resize(Selection.Rows.Count + 7).Select
    Selection.Copy
    Sheets("sheet2").Select
    Range("AH8").Select
    Selection.PasteSpecial Paste:=xlValues
End Sub

thanks though :)
Except ...

a) That does not do what was originally requested. The original requirement was to copy 7 rows in to AH8:AH14 of sheet2, whereas this copies 8 rows into AH8:AH15, and

b) The code has a whole lot of selections that are not required and just slow your code.

If you really want 8 rows then just make this change to VoG's code and you have it in one efficient line :)
Code:
Sheets("Sheet1").Range("AL" & Rows.Count).End(xlUp).Offset(-7).Resize(8).Copy Destination:=Sheets("Sheet2").Range("AH8")
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top