此公式根据该行中包含特定值的单元格为整个行着色。
For Each Cell In .Range("Y5:" & .Range("Y1500").End(xlDown).Address)
If .Cells(Cell.Row, 25).value = "Super Project" Then
Cell.EntireRow.Interior.Color = vR(WorksheetFunction.RandBetween(1, n))
End If
Next
End With
如何使“ B”列中的单元格也变为粗体?
答案 0 :(得分:0)
加粗单元格:Range.Font.Bold = True
您的目标单元格位于Col Y
(Col 25)中,因此要进入Col B
(Col 2),您需要向后移动(偏移值为)23列,结果是:
Cell.Offset(0,-23).Font.Bold = True
我的OCD一方坚持建议您
Y
=列25
。不需要.Cells(Cell.Row, 25)
。只需分析变量Cell
Cells
对象 和Cell
变量可能会引起混淆并导致错误。将Cell
更改为MyCell
之类的东西,以使区别显而易见。Dim MyCell as Range
With Sheets(1) 'Some Sheet
For Each MyCell In .Range("Y5:Y" & .Range("Y" & .Rows.Count).End(xlUp).Row)
If MyCell = "Super Project" Then
MyCell.EntireRow.Interior.Color = vR(WorksheetFunction.RandBetween(1, n))
MyCell.Offset(,-23).Font.Bold = True
End If
Next
End With