Find the first and last instance of a project in a data range

excelbytes

Active Member
Joined
Dec 11, 2014
Messages
251
Office Version
  1. 365
Platform
  1. Windows
Please see the attached example. I have a list of projects, and the list may have multiple instances of each project. I need to populate the grid in rows 12:14 with the column heading of the first and last instance of a 1 for that project. For example, Proj1 has the first "1" in columns A, C, & A, so A would go in the first block since that is where the first instance is of the three. Proj1 has the last "1" in F, G, & A (in the third instance, A is the first and last) so G would go in the second block.

I can accomplish this using a helper grid of SUMIFS for each Proj, but I am trying to do this with just a formula and no intermediate helper grid.

Is this possible without VBA? I also have to do this using Excel 2013.

Thanks in advance for your help.
 

Attachments

  • Projects.png
    Projects.png
    11.6 KB · Views: 5

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try this:

Book1
ABCDEFGHI
1
2ABCDEFGH
3Proj111
4Proj211
5Proj111
6Proj21
7Proj311
8Proj11
9Proj311
10
11FirstLast
12Proj1AG
13Proj2BG
14Proj3BF
Sheet4
Cell Formulas
RangeFormula
B12:B14B12=INDEX($2:$2,AGGREGATE(15,6,COLUMN($B$2:$I$2)/($A$3:$A$9=$A12)/($B$3:$I$9=1),1))
C12:C14C12=INDEX($2:$2,AGGREGATE(14,6,COLUMN($B$2:$I$2)/($A$3:$A$9=$A12)/($B$3:$I$9=1),1))
 
Upvote 0
Solution
It works perfectly. Again, thank you. It seems many of the formulas you have provided for me use the AGGREGATE function with dividing rather than the SMALL or LARGE functions with multiplication. I guess I need to spend more time understanding the AGGREGATE function. Can you explain why the AGGREGATE function with dividing works better than the SMALL or LARGE functions with multiplication?
 
Upvote 0
I think I just figured it out - if I multiplied, I would get a series of 1's and 0's, which would be fine for the LARGE option, but I don't want a 0 for the SMALL option, and using the option of 6 to ignore errors, it will eliminate all those that were FALSE and only choose the SMALL from number greater than 0, is that right?
 
Upvote 0
I think I just figured it out - if I multiplied, I would get a series of 1's and 0's, which would be fine for the LARGE option, but I don't want a 0 for the SMALL option, and using the option of 6 to ignore errors, it will eliminate all those that were FALSE and only choose the SMALL from number greater than 0, is that right?
Exactly! I don't know if AGGREGATE was designed to work like this, or if some clever soul figured out a way to make to work like this, but it's quite handy. There's another benefit to AGGREGATE too, in that it has some array processing built in to it. This formula was actually about the 4th version I did. The first 3 did not have AGGREGATE, but a combination of other functions and required the Control-Shift-Enter to make it work right. Once I got it working, I refined it down to the version I actually posted. I don't mind the CSE, but I avoid it when possible, since it's easy to forget and the formula won't work.

Anyway, glad I could help! :cool:
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,004
Members
449,203
Latest member
Daymo66

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