excel - 在特定日期后停止保存的电子表格上的条件格式
问题描述
我正在处理一个电子表格,我想在其中格式化下周即将到来的日期。代码工作正常,但下周过去后,格式继续,我不希望那样。我只希望从生成文件之日起的下一周进行格式化。为了澄清,我举个例子:
- 即将到来的一周 10 月 6 日至 10 月 12 日格式日期
- 保存存档
- 在 10 月 13 日重新打开文件,现在即将在 10 月 13 日至 10 月 19 日的一周被格式化
我想在任何时间点打开此保存的电子表格,并且仅格式化 10 月 6 日至 10 月 12 日这一周。这是我使用的代码,在生成电子表格的那一天之后,我可以输入一个命令来停止格式化吗?
Macro1 Macro
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Cells.Select
Range("B1").Activate
Selection.FormatConditions.Add Type:=xlTimePeriod, DateOperator:=7
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.Color = -16711681
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 5287936
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("D2").Select
ActiveWindow.SmallScroll Down:=-30
End Sub
解决方案
推荐阅读
- java - 如何刷新 JFrame
- python - 使用 plot 在 matplotlib 中将二维二进制矩阵绘制为一条线?
- windows - 在 Windows 上构建 ffmpeg 库
- python - Gurobipy:矩阵约束
- python - 我有一个函数,它有时返回 True,有时返回 False。我如何计算真假?
- python-3.x - 如何在 azure blob 存储中读取存储在 .py 文件中的变量
- c# - 为我的项目定义 LocalAppData 不起作用,因为它尝试在我的项目目录中查找 %LOCALAPPDATA%
- google-sheets - 请给我这个公式的 ArrayFormula
- game-development - 将 Navigation2D 限制为 4 个基点
- javascript - 如何在不丢失任何数据的情况下重新加载页面