[英]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. 我正在尝试创建一个公式,该公式将在日期单元格(C23:C28)的范围内查找,并查看它们是否包含与日期单元格B33中列出的月份相同的月份。 If so, I need it to remit the exact date listed in the matched cell (in column C).
如果是这样,我需要它汇出匹配单元格(在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). 该公式将所有日期(B33和C23:C28)转换为相关月份的第一天,然后进行比较-如果有任何匹配项(按年份和月份),则获得这些匹配项中的第一个(按在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 例如,如果您的所有日期始终是该月的1号,则可以简化操作
Try: 尝试:
=MIN(IF(MONTH(C23:C28)=B33,C23:C28)) = MIN(IF(MONTH(C23:C28)= B33,C23:C28))
To return the lowest date matching the month in B33. 返回与B33中月份匹配的最低日期。 Enter using [ctrl]+[shift]+[enter].
使用[ctrl] + [shift] + [enter]输入。
Using MAX does also require cse: 使用MAX还需要cse:
=MAX(IF(MONTH(C23:C28)=B33,C23:C28)) = MAX(IF(MONTH(C23:C28)= B33,C23:C28))
Or it will be in error without [ctrl]+[shift]+[enter]. 否则,如果没有[ctrl] + [shift] + [enter],它将是错误的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.