Excel 条件格式基于是否在当前显示的月份中
我正在创建一个工作日历,我希望它将一周中不属于当前显示月份的日子灰显。我在单元格 A1 中显示该月的第一天
如何使单元格 B3 中的单元格星期一和 B4 中的单元格具有灰色背景?
我知道这很简单,但我无法弄清楚。
谢谢
I am creating a work calendar and I want it to Grey out the Days of the week that are NOT part of the currently displayed month. I have the First Day of the Month Displayed in Cell A1
How can I make the Cell Monday in Cell B3 and the Cell in B4 to have a grey background?
I know this is simple but I cannot figure it out.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的示例,执行以下操作:
=MONTH($A$1)<>MONTH(A2) )
此公式的工作原理是简单地检查日期的月份数。
另请注意,公式会检查日期是否不相等,即如果日期与单元格 A1 中的日期不在同一月份,则设置不同颜色的格式。
如果您还想为匹配的日期添加格式,则只需在条件格式框中添加另一个条件并使用
=MONTH($A$1)=MONTH(A2)
Based on your example, do the following:
=MONTH($A$1)<>MONTH(A2)
This formula works by simply checking the month number of the date.
Note also that the formula check for inequality of dates i.e. if date is not in same month as that in cell A1 then format a different color.
If you also want to add a format for dates that do match then simply add another condition in the conditional formatting box and use
=MONTH($A$1)=MONTH(A2)
首页>款式>条件格式>突出显示单元格规则>发生的日期...>这个月
显然,如果您走这条路,您会将整个日历年设为灰色,然后设置条件格式以将当前月份设为白色。
Home > Styles > Conditional Formatting > Highlight Cells Rules > A Date Occuring... > This Month
Obviously if you go this route, you would make the whole calendar year gray and then set the conditional formatting to make the current month white.