Solved

Simple Excel Macro - Grab last row of a number and copy to new sheet

Posted on 2013-06-06
3
651 Views
Last Modified: 2013-06-06
Hi Excel Macro Experts,

I need a macro or formula that will grab the last number from a column that is the same and export it to a new spreadsheet/workbook.

Here is what the workbook looks like inside:

 ExampleImage
I have highlighted the rows that need to be copied to a new sheet.  Notice how Column F has numbers in it which are the same.  What I need the macro/formula to do is export the last set from the series and copy it to a new sheet.

I have attached the workbook to this question.  Thank you so much.
Example.xlsx
0
Comment
Question by:activematx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
NBVC earned 500 total points
ID: 39226975
Here's a formula solution...

In first sheet add a helper column in column T.

In T2:

=IF(F3<>F2,COUNT(T$1:T1)+1,"")

copied down

then in Sheet1, in A2:

=IFERROR(INDEX('FY2012 INVOICES'!A:A,MATCH(ROWS($A$2:$A2),'FY2012 INVOICES'!$T:$T,0)),"")

copied across to column S and down until you see blank rows... this gets you the info required.
0
 
LVL 9

Author Comment

by:activematx
ID: 39226995
Hi NB_VC

This is great.  It appears to work.  Would you mind briefly explaining to me what each formula does, so I can have a basic understanding of what was done.  Thanks so much!
0
 
LVL 23

Expert Comment

by:NBVC
ID: 39227078
The first formula just identifies and cumulatively counts the last occurance of each code in column F.

The Index formula, indexes the column to extract from, and matches a consecutively increasing number starting at 1 with the use of ROWS($A$2:$A2)... as you drag down this changes to ROWS($A$2:$A$3), and so on.  That number is matched to column T on other sheet... and since the formula there was consecutively numbering the matches, then the numbers are matched in sequence and the indexed column item extracted.

The IFERROR() returns a blank when you have copied down more rows than there are matches in other sheet.

As you copy across the Indexed column A:A changes to B:B, etc to get the adjacent column info.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question