特定边框的 VBA 条件格式
嘿嘿, 因此,我尝试使用 VBA 添加条件格式以补偿其他一些编码,这些编码会不时更改范围。我的问题是,我只将条件格式应用于 xlEdgeRight 和 xlEdgeLeft。但是,VBA总是告诉我它无法设置边框样式。有什么想法吗?
Dim rngMark As Range
Dim DateCond As FormatCondition
Dim BordNum As Long
Call wsDef
Set rngMark = wksS.Range("E11:CPB25")
rngMark.FormatConditions.Delete
Set DateCond = rngMark.FormatConditions.Add(Type:=xlExpression, Formula1:="=AND(TODAY()>=E$7,TODAY()<F$7)")
DateCond.SetFirstPriority
With DateCond
.StopIfTrue = False
.Font.ThemeColor = xlThemeColorAccent2
.Font.Bold = True
.Borders.LineStyle = xlNone
.Borders.LineStyle = xlNone
End With
For BordNum = 7 To 8
With DateCond.Borders(BordNum)
.LineStyle = xlContinuous
.TintAndShade = 0
.Color = -16776961
.Weight = xlThin
End With
Next BordNum
Hej,
So I am trying to use VBA to add conditonal formatting to compensate for some other coding, which changes the ranges from time to time. My problem is, that I only the conditional formatting to apply to xlEdgeRight
and xlEdgeLeft
. However, VBA always tells me that it cannot set the border style. Any ideas?
Dim rngMark As Range
Dim DateCond As FormatCondition
Dim BordNum As Long
Call wsDef
Set rngMark = wksS.Range("E11:CPB25")
rngMark.FormatConditions.Delete
Set DateCond = rngMark.FormatConditions.Add(Type:=xlExpression, Formula1:="=AND(TODAY()>=E$7,TODAY()<F$7)")
DateCond.SetFirstPriority
With DateCond
.StopIfTrue = False
.Font.ThemeColor = xlThemeColorAccent2
.Font.Bold = True
.Borders.LineStyle = xlNone
.Borders.LineStyle = xlNone
End With
For BordNum = 7 To 8
With DateCond.Borders(BordNum)
.LineStyle = xlContinuous
.TintAndShade = 0
.Color = -16776961
.Weight = xlThin
End With
Next BordNum
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编程格式条件——尤其是边框——有点特殊。
在这种情况下,您必须使用
xlLeft
= -4131 和xlRight
= -4152:Programming formatconditions - especially borders - is a bit special.
You have to use
xlLeft
= -4131 andxlRight
= -4152 in this case: