在条件格式中更改字体颜色

我试图根据定义的单元格的值,在这种情况下单元格“H”中的值更改单元格范围的颜色(“A”到“N”)。 我需要在“凭证”,“错误/票证”和“完成/备份”的情况下换成白色和粗体,而其他情况则保持黑色。

我有更改定义的范围的单元格颜色的代码,但我不知道如何应用代码的字体样式和颜色更改。 这是我到目前为止:

Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Columns("H")) Is Nothing Then On Error GoTo bm_Safe_Exit Application.EnableEvents = False Dim trgt As Range For Each trgt In Intersect(Target, Columns("H")) Select Case LCase(trgt.Value2) Case "2 day process" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 46 Case "advisor" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 37 Case "back in" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 22 Case "ci error/ticket" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 1 Case "completed" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 10 Case "completed/backup" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 51 Case "credentialing" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 49 Case "credit" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 44 Case "duplicate" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 10 Case "held" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 37 Case "master data" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 37 Case "name change" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 37 Case "ofr" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 3 Case "op consultant" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 37 Case "post process" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 32 Case "pps" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 37 Case "react acct" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 37 Case "rejected" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 10 Case "transferred" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 10 Case "zpnd" Cells(trgt.Row, "A").Resize(1, 14).Interior.ColorIndex = 37 Case Else Cells(trgt.Row, "A").Resize(1, 14).Interior.Pattern = xlNone End Select Next trgt End If bm_Safe_Exit: Application.EnableEvents = True End Sub 

您必须访问单元格的Font属性。 所以在你的情况

 Cells(trgt.Row, "A").Resize(1, 14).Font.ColorIndex = 1 Cells(trgt.Row, "A").Resize(1, 14).Font.FontStyle = "Bold"