トップページ(目次)

062.条件付き書式を設定する

<実行前後>
 → 
Sub 条件付き書式を設定する()

    最終行 = Cells(Rows.Count, "A").End(xlUp).Row
    
    '最初に条件付き書式を毎回削除しないと、同じ条件付き書式を重ねてしまうことがあるため
    Cells.FormatConditions.Delete
    
    'Aを含む場合、緑にする
    Range("A2:A" & 最終行).FormatConditions.Add Type:=xlExpression, Formula1:="=COUNTIF($A2,""*A*"")"
    Range("A2:A" & 最終行).FormatConditions(1).Interior.Color = RGB(1, 255, 1)
    
    '13より多い場合、青にする
    Range("B2:B" & 最終行).FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, Formula1:="=13"
    Range("B2:B" & 最終行).FormatConditions(1).Font.ThemeColor = xlThemeColorDark1
    Range("B2:B" & 最終行).FormatConditions(1).Interior.Color = RGB(1, 1, 255)

End Sub

Copyright © 2021 https://excel3000.web.fc2.com/ All Rights Reserved.
    inserted by FC2 system