简体   繁体   English

Excel 中的条件格式比较单元格之间的日期

[英]Conditional Formating in Excel comparing dates between cells

I have 2 columns that have conditional formatting to compare the Day and Time in the cells.我有 2 列具有条件格式来比较单元格中的日期和时间。

M compares against K, N compares against L M 与 K 比较,N 与 L 比较

In both cases, if the cell data is <= then it should return Green.在这两种情况下,如果单元格数据 <= 则它应该返回绿色。 If > then it should return Red.如果 > 那么它应该返回红色。

I have done 45 other data entries and every day and time worked perfectly until the last row.我已经完成了 45 个其他数据条目,并且每一天和每一时间都完美地工作,直到最后一行。 They are the only cells showing Friday.它们是唯一显示星期五的单元格。 Any ideas why this is happening?任何想法为什么会这样?

I have an example in the images showing the row just above it where the formatting is working just fine.我在图像中有一个示例,显示其正上方的行,格式工作得很好。

Also, the format for the cells is dddd hh:mm.此外,单元格的格式为 dddd hh:mm。

在此处输入图像描述 在此处输入图像描述 在此处输入图像描述

I did a quick validation formula to see if N46 > L46, produce Y and it does flag as being greater for some reason.我做了一个快速验证公式来查看 N46 > L46 是否产生 Y,并且由于某种原因它确实标记为更大。 在此处输入图像描述

You will need helper columns to retrieve a date from your strings.您将需要辅助列来从您的字符串中检索日期。

You can use this formula - maybe it makes sense to create a LAMBDA function from that (look for according tutorials) - where A3 is the cell with your data (eg Friday 11:30)您可以使用这个公式 - 也许从中创建一个 LAMBDA function 是有意义的(查找相应的教程) - 其中 A3 是包含您的数据的单元格(例如星期五 11:30)

=LET(d,A3,
day,TEXTBEFORE(d," "),time,TEXTAFTER(d," "),
weekdays,{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"},
weekdayIndex, MATCH(day,weekdays,0), (TODAY() + (weekdayIndex-WEEKDAY(TODAY(),2) +1) ) + time)

Then you can use the helper columns for your conditiona formatting.然后您可以使用辅助列来设置条件格式。

(I tried: it is not possible to use a LAMBDA function as formula for the conditional formatting). (我试过:不可能使用 LAMBDA function 作为条件格式的公式)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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