Sub Main()
Range("A1").Select
Do While ActiveCell.Value <> ""
If hasKeyword(ActiveCell.Value) Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Else
Selection.Interior.ColorIndex = xlNone
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Function hasKeyword(ByVal str As String) As Boolean
If str = "2020" Or str = "2011" Or str = "2010" Or str = "korea" Or str = "english" Or str = "南" Then
hasKeyword = True
Exit Function
End If
hasKeyword = False
End Function
條件式格式設定
先在D欄打好要黃底的關鍵字。
將A欄資料框選起來。
再點取「常用 > 條件式格式設定 > 新增規則」指令。
格式設定如下:
結果如下: