A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

how do I copy the last 20 entries in an expanding list



 
 
Thread Tools Display Modes
  #1  
Old April 25th, 2010, 03:55 AM posted to microsoft.public.excel.worksheet.functions
DJA
external usenet poster
 
Posts: 12
Default how do I copy the last 20 entries in an expanding list

Within a macro, I need to copy the last 20 entries of a list to another
location.
as the list grows, I still only need the last 20 entries to copy to the
location.
in lotus I would write "end down" "up 20" then copy & move.

I can't find a corresponding formula in excel.

when I try using end down in the macro and copy... it seems to always use
the original space rather than the new space as new entries are listed.
  #2  
Old April 25th, 2010, 04:11 AM posted to microsoft.public.excel.worksheet.functions
ozgrid.com
external usenet poster
 
Posts: 328
Default how do I copy the last 20 entries in an expanding list

Assumes list is Column "A" and is contiguous

Sub CopyLastX()
Dim rRange As Range

Set rRange = Range(Cells(Rows.Count, 1).End _
(xlUp).Offset(-20, 0), Cells(Rows.Count, 1).End(xlUp))

MsgBox rRange.Address
End Sub


--
Regards
Dave Hawley
www.ozgrid.com
"DJA" wrote in message
...
Within a macro, I need to copy the last 20 entries of a list to another
location.
as the list grows, I still only need the last 20 entries to copy to the
location.
in lotus I would write "end down" "up 20" then copy & move.

I can't find a corresponding formula in excel.

when I try using end down in the macro and copy... it seems to always use
the original space rather than the new space as new entries are listed.


  #3  
Old April 25th, 2010, 08:14 AM posted to microsoft.public.excel.worksheet.functions
Max
external usenet poster
 
Posts: 8,574
Default how do I copy the last 20 entries in an expanding list

I can't find a corresponding formula in excel

You could try this multi-cell array formula
Assume your source data is in A2:B2 down, contiguous & expected to vary up
to say, A2:B1000
Select a 20 cell col range, say D221 (with D2 active)
Copy n paste this into the formula bar (ie for D2), then press
CTRL+SHIFT+ENTER to confirm the formula into D221 at one go (ie multi-cell
array-enter):
=OFFSET(INDIRECT("A"&MAX(IF(A$2:A$1000"",ROW(A$2 :A$1000)))),,COLUMNS($A:A)-1,-20)
Copy D221 across to E21. D2:E21 will return the last 20 rows of the source
data in cols A and B as it expands up to row 1000. The formula monitors the
last filled cell in col A, then grabs 20 rows from there upwards (via the
"-20" height param in the OFFSET). Tested ok here. Success? hit the YES below
--
Max
Singapore
---
"DJA" wrote:
Within a macro, I need to copy the last 20 entries of a list to another
location.
as the list grows, I still only need the last 20 entries to copy to the
location.
in lotus I would write "end down" "up 20" then copy & move.

I can't find a corresponding formula in excel.

when I try using end down in the macro and copy... it seems to always use
the original space rather than the new space as new entries are listed.

  #4  
Old April 25th, 2010, 02:39 PM posted to microsoft.public.excel.worksheet.functions
Teethless mama
external usenet poster
 
Posts: 3,722
Default how do I copy the last 20 entries in an expanding list

Assuming your data in column A

If your data are 'text' value then use this:
=INDEX(A:A,MATCH("zzzzz",A:A)+ROWS($1:1)-20)

copy down to next 19 rows


If your data are 'numeric' value then use this:
=INDEX(A:A,MATCH(10^10,A:A)+ROWS($1:1)-20)

copy down to next 19 rows



"DJA" wrote:

Within a macro, I need to copy the last 20 entries of a list to another
location.
as the list grows, I still only need the last 20 entries to copy to the
location.
in lotus I would write "end down" "up 20" then copy & move.

I can't find a corresponding formula in excel.

when I try using end down in the macro and copy... it seems to always use
the original space rather than the new space as new entries are listed.

  #5  
Old April 25th, 2010, 02:54 PM posted to microsoft.public.excel.worksheet.functions
Teethless mama
external usenet poster
 
Posts: 3,722
Default how do I copy the last 20 entries in an expanding list

If your data are mixed with 'text' and 'numeric' values in a column
example:

cat
dog
24
33
chicken
44
and so on..

=INDEX(A:A,MAX(MATCH("zzzzz",A:A),MATCH(10^10,A:A) )+ROWS($1:1)-20)
copy down to next 19 rows





"DJA" wrote:

Within a macro, I need to copy the last 20 entries of a list to another
location.
as the list grows, I still only need the last 20 entries to copy to the
location.
in lotus I would write "end down" "up 20" then copy & move.

I can't find a corresponding formula in excel.

when I try using end down in the macro and copy... it seems to always use
the original space rather than the new space as new entries are listed.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:44 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.