2010 Access VBA 在 Excel 中设置条件格式
2010 Access VBA setting conditional formatting in Excel
我找到了 Excel VBA 的答案,但我无法将其转换为 Access VBA (Conditional Formatting using Excel VBA code)。
这是我当前的代码:
with ws
With .Cells(1, 1).FormatConditions.Add(Type:=xlExpression, Formula1:="=IF($J2=""Y"";TRUE;FALSE)")
.Font.Color = -10092544
.StopIfTrue = False
StrSearchCriteria = "A2:D" & lRow
.FormatConditions(1).ModifyAppliesToRange Range(StrSearchCriteria)
End With
With .Cells(1, 1).FormatConditions.Add(xlCellValue, xlEqual, "=""Closed (New)""")
.Font.Color = -16776961
.StopIfTrue = False
StrSearchCriteria = "A2:K" & lRow
.FormatConditions(2).ModifyAppliesToRange Range(StrSearchCriteria)
End With
End With
我收到错误 "Invalid procedure call or argument"。
我错过了什么?
谢谢
我找到了这个答案:Adding a format condition in Excel through Access VBA。
但是,当我只是尝试删除任何现有的条件格式时(作为使用链接答案中的代码测试方法)我收到错误 "Object does not support this property or method." 代码是:
with wks
.Range("A:D").Selection.FormatConditions.Delete
end with
非常感谢对此的任何帮助。
您不需要引用所选内容。尝试:
.Range("A:D").FormatConditions.Delete
我找到了 Excel VBA 的答案,但我无法将其转换为 Access VBA (Conditional Formatting using Excel VBA code)。
这是我当前的代码:
with ws
With .Cells(1, 1).FormatConditions.Add(Type:=xlExpression, Formula1:="=IF($J2=""Y"";TRUE;FALSE)")
.Font.Color = -10092544
.StopIfTrue = False
StrSearchCriteria = "A2:D" & lRow
.FormatConditions(1).ModifyAppliesToRange Range(StrSearchCriteria)
End With
With .Cells(1, 1).FormatConditions.Add(xlCellValue, xlEqual, "=""Closed (New)""")
.Font.Color = -16776961
.StopIfTrue = False
StrSearchCriteria = "A2:K" & lRow
.FormatConditions(2).ModifyAppliesToRange Range(StrSearchCriteria)
End With
End With
我收到错误 "Invalid procedure call or argument"。
我错过了什么? 谢谢
我找到了这个答案:Adding a format condition in Excel through Access VBA。
但是,当我只是尝试删除任何现有的条件格式时(作为使用链接答案中的代码测试方法)我收到错误 "Object does not support this property or method." 代码是:
with wks
.Range("A:D").Selection.FormatConditions.Delete
end with
非常感谢对此的任何帮助。
您不需要引用所选内容。尝试:
.Range("A:D").FormatConditions.Delete