简体   繁体   中英

Excel Formula: How to match a part of one cell to the part of another and remit the matched cell's value

I am trying to create a formula that will look in the range of date cells (C23:C28) and see if any of them contain the same month as the month listed in date cell B33. If so, I need it to remit the exact date listed in the matched cell (in column C). Any insight will help. Thanks!

Try this formula

=IFERROR(INDEX(C23:C28,MATCH(B33-DAY(B33)+1,INDEX(C23:C28-DAY(C23:C28)+1,0),0)),"No match")

The formula converts all dates (B33 and C23:C28) to the 1st of the relevant month and then makes the comparison - if any match (by year and month) you get the first of those matches (in order of placement in C23:C28). If there are no matches you get "No match"

You might be able to simplify if, say, all your dates will always be 1st of the month

Try:
=MIN(IF(MONTH(C23:C28)=B33,C23:C28))
To return the lowest date matching the month in B33. Enter using [ctrl]+[shift]+[enter].

Using MAX does also require cse:
=MAX(IF(MONTH(C23:C28)=B33,C23:C28))
Or it will be in error without [ctrl]+[shift]+[enter].

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM