色が一色しか選べないと不なので、色を選択できるようにします。
下の図のように、チェックボックスを4つ配置します。
実行をクリックしたときのコードを次のように変更します。
Private Sub CommandButton1_Click()
Dim a As Integer
Dim b As Integer
For a = TextBox2 To TextBox4 Step 2
For b = TextBox1 To TextBox3
Cells(a, b).Select
If CheckBox1.Value = True Then ‘青
Selection.Interior.Color = 12611584
End If
If CheckBox2.Value = True Then ‘緑
Selection.Interior.Color = 5287936
End If
If CheckBox3.Value = True Then ‘黄
Selection.Interior.Color = 65535
End If
If CheckBox4.Value = True Then ‘赤
Selection.Interior.Color = 255
End If
Next b
Next a
End Sub
CheckBoxの名前は変えずにそのまま使います。
チェックボックスの名前を青とか色の名前にするのもいいのですが、今回は
そこまでしなくてもいいかなと思います。
若干趣味の世界に入り始めましたが、この方が便利かなと思います。
本日も最後までお付き合い頂きありがとうございます。