copy last 5 populated cells

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,602
Office Version
  1. 365
Platform
  1. Windows
Can I please have help to get code to carry out simple task below

Find last populated cell through Column A of Sheet1

From that cell select the next 5 cells UP for both columns A and B and copy that data into cell D1

So if A50 is the last populated cell, the code would copy A45:B50 into D1

Many thanks in advance
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Yes, you are! If these are numbers, try this:
May be easier to copy

in D1 and copy down
Code:
=INDEX(A:A;COUNTA(A:A)-(5-ROW(A1));1)
or
Code:
=OFFSET($A$1,MATCH(MAX($A$1:$A$12)+1,$A$1:$A$12,1)-(6-ROW(A1)),0)

my regards
Any good I want you in the New Year
 
Last edited:
Upvote 0
Yes, there are always neater ways! Mine was a bit rough and ready ... ;)

Happy New Year to you, too, Navic! :)
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,472
Members
449,087
Latest member
RExcelSearch

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