对于VBA来说非常新,并且一直在努力尝试将下标超出范围的几个小时: .FormatConditions(1).Add Type:= xlCellValue,Operator:= xlLess,_ 一级方程式:=" = 0.5" 我错过了什么?
With ActiveSheet
Columns(4).Select
Range("D3").Activate
With Columns("D:D")
.FormatConditions.Delete
.FormatConditions(1).Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=0.5"
.FormatConditions(1).NumberFormat = "0.000"
.FormatConditions(1).StopIfTrue = False
.FormatConditions(2).Add Type:=xlCellValue, Operator:=xlGreaterEqual, _
Formula1:="=0.5"
.FormatConditions(2).NumberFormat = "#,##0.0"
.FormatConditions(2).StopIfTrue = False
ActiveSheet.Next.Select
End With
End With
End Sub
答案 0 :(得分:0)
添加条件时语法问题。你也可以省去我认为的选择。
With ActiveSheet.Columns("D:D")
.FormatConditions.Delete
.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="=0.5"
.FormatConditions(1).NumberFormat = "0.000"
.FormatConditions(1).StopIfTrue = False
.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual, _
Formula1:="=0.5"
.FormatConditions(2).NumberFormat = "#,##0.0"
.FormatConditions(2).StopIfTrue = False
End With