Excel 条件格式基于是否在当前显示的月份中

发布于 2024-10-10 11:15:01 字数 140 浏览 0 评论 0原文

我正在创建一个工作日历,我希望它将一周中不属于当前显示月份的日子灰显。我在单元格 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雪落纷纷 2024-10-17 11:15:01

根据您的示例,执行以下操作:

  1. 选择单元格 A2:G13(即要设置格式的日期)
  2. 现在选择 格式 >条件格式...
  3. 在第一个下拉菜单中选择公式为
  4. 在下一个文本框中输入以下公式:=MONTH($A$1)<>MONTH(A2) )
  5. 现在,为与单元格 A1 中的日期不匹配的单元格设置所需的格式。

此公式的工作原理是简单地检查日期的月份数。

另请注意,公式会检查日期是否不相等,即如果日期与单元格 A1 中的日期不在同一月份,则设置不同颜色的格式。

如果您还想为匹配的日期添加格式,则只需在条件格式框中添加另一个条件并使用 =MONTH($A$1)=MONTH(A2)

Based on your example, do the following:

  1. Select cell A2:G13 (i.e the dates you want to format)
  2. Now select Format > Conditional Formatting...
  3. In the first drop down menu select Formula Is
  4. In the next textbox enter this formula: =MONTH($A$1)<>MONTH(A2)
  5. Now set the formatting you want for cells that do not match date in cell A1

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)

善良天后 2024-10-17 11:15:01

首页>款式>条件格式>突出显示单元格规则>发生的日期...>这个月

显然,如果您走这条路,您会将整个日历年设为灰色,然后设置条件格式以将当前月份设为白色。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文