[英]Conditional formatting VBA not highlighting cell in a specific cell in a worksheet
I had a quick question about the conditional formatting part of my code, 我对代码的条件格式部分有一个快速的疑问,
the rest of the code works perfect but when I get to the conditional formatting part, the row I wanted to highlight doesn't. 其余代码工作完美,但是当我到达条件格式部分时,我要突出显示的行却没有。 I want the row with to be highlighted based on a value that is on cell H5 on the copysheet area.
我希望基于电子表格区域上单元格H5上的值突出显示带有的行。
cell H5 has the formala =MAX(IF(ISERROR("L8:L2500,"",L8:2500") which finds the max value in range L 单元格H5的形式为= MAX(IF(ISERROR(“ L8:L2500,”“,L8:2500”)),它查找范围L中的最大值
is there any way to apply conditional formatting to search for that max value? 有什么方法可以应用条件格式来搜索该最大值?
Sub Search()
Dim vCrit As Variant
Dim filtersheet As Worksheet
Dim copysheet As Worksheet
Dim rngCrit As Range
Dim rngList As Range
Set filtersheet = Worksheets("Datalog")
Set copysheet = Worksheets("Line Inquiry")
filtersheet.Unprotect
Set rngCrit = filtersheet.Range("$A$7:$L$2500").CurrentRegion
Set rngList = copysheet.Range("B5")
vCrit = Sheets("Datalog").Range("O3")
copysheet.Range("A8:K2500").Clear
With filtersheet
rngCrit.AutoFilter _
Field:=3, _
Criteria1:=Application.Transpose(vCrit), _
Operator:=xlFilterValues
rngCrit.SpecialCells(xlCellTypeVisible).Copy
copysheet.Range("A7").PasteSpecial xlPasteFormulasAndNumberFormats
Application.CutCopyMode = False
Application.ScreenUpdating = False
filtersheet.AutoFilterMode = False
filtersheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
copysheet.Range("A8:L2500").FormatConditions.Delete
With copysheet.Range("$A8:$L8").FormatConditions.Add( _
Type:=xlExpression, _
Formula1:="=$H$5=$L8")
.Interior.Color = RGB(198, 239, 206)
.Font.Color = RGB(0, 97, 0)
End With
End With
'returning to original sheet
copysheet.Range("B5").Select
End Sub
You could do your formatting in your code. 您可以在代码中进行格式化。 Something like this.
这样的事情。
if somecondition then
copysheet.Range("I" & lRow).Font.ColorIndex = 3
End if
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.