Audra
Audra

Reputation: 13

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!

Upvotes: 0

Views: 553

Answers (2)

Steve
Steve

Reputation: 1648

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].

Upvotes: 0

barry houdini
barry houdini

Reputation: 46401

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

Upvotes: 1

Related Questions