1
我有条件格式的VBA代码。将VBA代码转换为在vbscript中运行
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotBetween, _
Formula1:="=$I$10", Formula2:="=$J$10"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
我有一个VBScript创建Excel工作表,我需要将VBA代码应用到Excel工作表创建时的单元格中。有问题让它运行。我知道我需要为Excel常量子的实际值,但还有更多的它,我只是不明白
我所做到目前为止
priceRange = "K"&rowNum + 2
objWorkSheet.Range(priceRange).FormatConditions.Add Type:=1, Operator:=2, Formula1:="=$I$"&finalRowNum + 1&"", Formula2:="=$J$"&finalRowNum + 1&""
objWorkSheet.Range(priceRange).FormatConditions(objExcel.Selection.FormatConditions.Count).SetFirstPriority
objWorkSheet.Range(priceRange).FormatConditions(1).Interior.PatternColorIndex = -4105
objWorkSheet.Range(priceRange).FormatConditions(1).Interior.Color = 255
objWorkSheet.Range(priceRange).FormatConditions(1).Interior.TintAndShade = 0
objWorkSheet.Range(priceRange).FormatConditions(1).StopIfTrue = False
我需要它来申请条件格式在一个特定的细胞(我定义为priceRange一)
你能发布更多的代码?我看到你正在使用“选择”很多,这可能会导致错误(你想[避免](http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel- vba-macros),只要有可能就使用“select”)。 – BruceWayne
@ user3578951这就是生成的vba宏excel。由于excel对象在完成脚本之前处于隐藏状态,因此我需要将其应用于特定的行。我会编辑我所做的,但我知道这是错误的。我确实得到了常量,但我不知道该从哪里去。 – asdfasfd
如果您发布最小,完整,可验证的示例代码(http://stackoverflow.com/help/mcve)并解释您期望的结果以及获得的结果,您将获得更多帮助。 – Joe