This formula:
finds the last row containing text in column A.
REPT("z",255) creates a string of 255 z's. MATCH() looks for this string in Column A... and since we did not use the Match_type 3rd argument, then Match() looks for the last cells that contains text that is smaller than or equal to the string of z's.. which would obviously be the last cell with any other text.
The other formulas are not easy to explain.....but I will try....
Note: If you use the Formula Audit tool in Tools|Formula Auditing|Evaluate Formula you can follow the steps of the Formula evaluation.
The formula in G2:
first checks to see if the current value in C is the same as the previous row's value, and enters a blank if it is. This is so the same result isn't repeated down the "group of Regions". If it is not the same, it assumes it is the first of the group and calculates the sum of the group.... To identify the group (since you have duplicates even further down that you don't want to include, we can't use Sumproduct), we have to figure out where the group ends....
this part:
does that. It starts at current row's F cell and goes to where the first time a Region in C doesn't match the current row's region. MATCH(TRUE,INDEX(....))) creates an array of TRUEs and FALSEs based on if each item in Column C matches current C value or not. It returns the position of the first TRUE and Indexes that agains column F to return the bottom of the SUM range. The -1 is to back up one row so that it goes only to the last row where C matches current row C value.
The formula in H2 is similar but it is grouping by column B (or CNTRCT_ID)... but this time we need to always refer to first and last row in specific CNTRCT_ID group in each cell within column H of the respective groups in order to acquire the SUM range...
So then the F2 after the SUM( opening is replaced by:
This finds the last time that a value in column B is not equal to the current column B value... so MATCH is now looking for a 2 in the results of 1/(B$1:B2<>B2). The results will either be 1 because 1/TRUE is 1 or #DIV/0! error because 1/FALSE is 1/0 which is error.... so again there is no 3rd Match_type argument in this MATCH() function and so it looks for the last time a value in the array is less than or equal to 2... the function ignores errors and so finds the last 1 and returns the corresponding indexed cell reference from column F.... to indicate the first of the group...
Hope this helps explain it a bit...
Bookmarks