Skip to content

Instantly share code, notes, and snippets.

@eggist77
Last active May 28, 2022 04:41
Show Gist options
  • Save eggist77/3143a27721ce867416f65f404f7bf17f to your computer and use it in GitHub Desktop.
Save eggist77/3143a27721ce867416f65f404f7bf17f to your computer and use it in GitHub Desktop.
vba formatCondition.vb
Sub formatCondition()
Dim r As Range
Dim formatCondition As FormatCondition
'範囲設定
Set r = Range("A1:A5")
'条件付き書式の追加
Set formatCondition = r.FormatConditions.Add(Type:=xlTextString, String:="OK", TextOperator:=xlContains)
'書式の指定(濃い緑の文字、緑の背景)
With formatCondition.Font
.Color = RGB(0, 97, 0)
.TintAndShade = 0
End With
With formatCondition.Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(198, 239, 206)
.TintAndShade = 0
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment