我有一个规格范围,如果该值超出规格范围,则我希望条件格式代码引用并用一种颜色(或无颜色)填充该单元格。它适用于某些数字,而不是所有数字。例如,如果将低规格范围设置为305,并且将305输入到数据单元中,则当不应将其高亮显示为不合规格的红色。但是,如果低规格范围是299,并且输入299,则不会突出显示这正是我想要的。高规格也是如此。
请记住,我的低规格/高规格范围是通过vlookup提取的,所以我不确定是否是造成此问题的原因?
希望所有这些都是有道理的。
谢谢!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lowspec As Double, highspec As Double
Dim width As Range
Dim C As Range
lowspec = Me.Range("l6")
highspec = Me.Range("p6")
Set width = Intersect(Target, Me.Range("i16:o101"))
Application.EnableEvents = False
If Not width Is Nothing Then
For Each C In width.Cells
v = C.Value
If Len(v) > 0 Then
Select Case v
Case Is < lowspec: newcolor = 3
Case Is > highspec: newcolor = 45
End Select
Else
newcolor = xlNone
End If
C.Interior.ColorIndex = newcolor
Next C
End If
Application.EnableEvents = True
End Sub