我想要做的是:如果D列上的单元格表示汽车,则检查右侧的最后一个单元格(行上的最后一个单元格),如果该值小于20%,则突出显示。 (这是代码的最后一部分):
这是我到目前为止,但我无法弄清楚如何解决它。我必须为工作做这件事,但我很困惑谢谢!
Worksheets("Report").Activate
Call VBA
Dim lrow As Integer
Dim xrow As Integer
Dim FR As Range
Dim MR As Range
Dim cell As Range
lrow = wsr.Cells(Rows.Count, 3).End(xlUp).Row
xrow = wsr.Cells(Rows.Count, 3).End(xlToRight)
Set FR = Range("D12:D" & lrow)
For Each cell In FR
If cell.Value = "Cars" then for cell.xrow if cell.Value > 0.20 then Then cell.Interior.Color = RGB(224, 202, 224)
通过Xrow我的意思是行上的最后一个单元格。
谢谢!
答案 0 :(得分:2)
试试这个:
For Each cell In FR
If cell.Value = "Cars" Then
If Cells(cell.Row, Columns.Count).End(xlToLeft).Value < 0.2 Then
cell.Interior.Color = vbRed
End If
End If
Next
然而,斯科特克拉纳的答案是一个更优雅的解决方案。
答案 1 :(得分:2)