问题
I am struggling with a formula and need help.
I have two tables: Table 1 - containing columns'.
"Cust_ID" and "Enrolled date"
Table 2 -containing
"Cust_ID" and "Invoice_date"
i need to match cust_ID and return the next date from invoice date column after enrolled date.
I used following formula but it didn't really worked for me.
=INDEX($G$2:$G$13,MATCH(A4,$F$2:$F$13,-1))
Please help.
回答1:
If you do not want to sort your data then you will need an Array formula like this:
=INDEX($G$2:$G$13,MATCH(MIN(IF(($G$2:$G$13>=B2)*($F$2:$F$13=A2),$G$2:$G$13-B2)),IF(($G$2:$G$13>=B2)*($F$2:$F$13=A2),$G$2:$G$13-B2),0))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when editing edit mode. If done correctly then Excel will put {}
around the formula.
Click on C2. Put the formula in the formula bar. Click Ctrl-Shift-Enter. Then copy/drag down.
来源:https://stackoverflow.com/questions/41186700/excel-match-column-and-find-next-value-after-a-given-date