excel - 通过字符串中的前几个字母进行条件格式[VBA]
问题描述
我试图通过应用 .FormatConditions.Add(xlTextString, etc.)
到一个范围使一些 VBA 单元格的字体变粗。
如果该范围内的单元格的值以字母“V”开头,我想加粗该范围内的单元格
下面是我正在使用的代码的一部分。我有兴趣从这里获得功能性结果,但我不确定从这里去哪里 - 任何人都可以建议吗?
With .Range("L2:EZ5000").FormatConditions
.Add(xlTextString,)
End With
解决方案
从宏记录器:
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, _
Formula1:="=LEFT(A1,1)=""V"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
并整理:
Dim rng As Range, fc As FormatCondition
Set rng = Selection
rng.FormatConditions.Delete
With rng.FormatConditions.Add(Type:=xlExpression, _
Formula1:="=LEFT(" & rng.Cells(1).Address(False, False) & ",1)=""V""")
.SetFirstPriority
.Font.Bold = True
.StopIfTrue = False
End With
推荐阅读
- powershell - 我们可以在部署时阻止 Azure LogicApp 触发器触发吗
- azure - Azure DevOps 团队日历缺少一天休假的用户
- javascript - 拼接方法不正确
- c++ - 带字节序的 bit_cast 是否足以避免未定义的行为?
- python - 如何在python中使用正则表达式捕获千位和小数分隔符的价格
- iphone - IOS15 升级后 Iframe 内容未加载到 Iphone 中
- git - 使用 git lfs 克隆时如何发送 http 标头以进行基本身份验证
- scala - 如何在喷雾中使用嵌套对象序列化超过 22 个字段?
- javascript - (表达,反应)如何通过 mySQL 从外键中获取数据?
- javascript - 下一个导出脚本不适用于下一个/图像组件