代码运行没有任何错误,但条件格式不起作用。我们也可以使用 Address.Eg 偏移单元格cf = blue.Address(orow / 2 - 1, -ocol / 2)
。
blue.Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
cf = blue.Address(orow / 2 - 1, -ocol / 2)
cf1 = blue.Address(orow / 2 - 1, ocol / 2)
cf2 = blue.Address(-orow / 2 - 1, -ocol / 2)
cf3 = blue.Address(-orow / 2 - 1, ocol / 2)
Selection.FormatConditions.Add Type:=xlExpression, Formula1:=_
"=OR(LEN(cf.address)=0, LEN(cf1.address)=0,LEN(cf2.address)=0,LEN(cf3.address)=0)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.ThemeColor = xlThemeColorAccent5
.TintAndShade = 0.8
End With
Selection.FormatConditions(1).StopIfTrue = False
End With
并非所有代码都已发布且难以评估所有代码。但尝试更换:
"=OR(LEN(cf.address)=0, LEN(cf1.address)=0,LEN(cf2.address)=0,LEN(cf3.address)=0)"
和
"=OR(LEN(" & cf.address & ")=0, LEN(" & cf.address & ")=0,LEN(" & cf.address & ")=0,LEN(" & cf.address & ")=0)"
否则,VBA 将所有内容都视为字符串,而不关心您的变量......
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句