LoginSignup
0
0

More than 1 year has passed since last update.

Excelエビデンス作成用マクロ

Posted at

用途

エクセルで、期待値と実施結果を比較するマクロ。
マクロを実行すると期待値と実施結果が異なる箇所のセルが赤くなる(条件付き書式を設定している)。

  • i:期待値のデータ開始行
  • s:実施結果のデータ開始行
  • e:実施結果のデータ終了行
  • col_s:データ開始列
  • col_e:データ終了列

下のようなイメージの使い方ができる。
image.png

マクロ

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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0