用途
エクセルで、期待値と実施結果を比較するマクロ。
マクロを実行すると期待値と実施結果が異なる箇所のセルが赤くなる(条件付き書式を設定している)。
- i:期待値のデータ開始行
- s:実施結果のデータ開始行
- e:実施結果のデータ終了行
- col_s:データ開始列
- col_e:データ終了列
マクロ
Sub test_checker()
Dim i As Integer
Dim s As Integer
Dim e As Integer
i = 3
s = 246
e = 354
Dim col_s As String
Dim col_e As String
col_s = "B"
col_e = "OU"
Dim k As Integer
For k = s To e
Dim c As Range
Set c = Range(col_s & k, col_e & k)
Dim formla As String
formla = "IF(TEXT(" & col_s & i & ",\""@\"")<>TEXT(" & col_s & k & ",\""@\""),1,0)"
c.FormatConditions.Add Type:=xlExpression, Formula1:="=IF(TEXT(" & col_s & i & ",""@"")<>TEXT(" & col_s & k & ",""@""),1,0)"
c.FormatConditions(1).Interior.Color = XlRgbColor.rgbRed
i = i + 1
Next
End Sub