Formula:
=IF(OR(D6="",ISNUMBER(SEARCH("assembly #",A6,1))),"",IF(COUNTIF($D$6:D6,D6)>1,MAX($G$5:G5),MAX($G$5:G5)+1))
This is a "nested IF" formula. The first part of the first IF =IF(OR(D6="",ISNUMBER(SEARCH("assembly #",A6,1))) is the condition that looks at D6 and A6 and if either one is true, return the TRUE part of the formula which is "" or a blank cell. If D6 is blank OR ISNUMBER gives TRUE or FALSE looking for numeric values in its argument which in this case is the search for the string: assembly # in cell A6. If assembly # is found by the SEARCH, 1 is returned and therefore the ISNUMBER will be TRUE.
The second IF conditionally counts a dynamic range starting in D6 for the value D6 (which will also change as the range expands). If this value is greater than 1, take the MAX value of the dynamic range that starts in G5. If the value is FALSE, then take the max value of the range starting in G5 and add 1 to that value.
If the formula is dragged down the column, values in A7, D7 etc are evaluated along with the ranges that start in D6 and G5.
I hope this helps.
Bookmarks