VBA セル入力規則の設定(Validation) セル入力規則の設定(Validation) 構文 Validation.Add(Type, AlertStyle, Operator, Formula1, Formula2) Sub test() ’ リスト指定 With Range("B2:B5").Validation .Delete ’これまでの入力規則を削除 .Add Type:=xlValidateList, _ Operator:=xlEqual, _ Formula1:="大阪,東京,名古屋,福岡,札幌" End With End Sub Sub test2() ’ リスト指定 他のシート範囲を参照 With Range("B2:B10").Validation .Delete ’これまでの入力規則を削除 .Add Type:=xlValidateList, _ Formula1:="=Sheet1!$A$1:$A$5" End With End Sub Sub test3() ’ 1~12の間の整数 With Range("B2:B10").Validation .Delete ’これまでの入力規則を削除 .Add Type:=xlValidateWholeNumber, _ Operator:=xlBetween, _ Formula1:=1, Formula2:=12 End With End Sub セル入力規則の削除 Sub test4() ’ 入力規則の削除 Range("B2:B10").Validation.Delete End Sub 関連記事 VBA セル罫線操作(罫線太さや色) VBA セル罫線操作(罫線種類) VBA セル罫線操作(罫線位置) VBA セルの操作 文字書体設定 VBA セルの操作 もじ色の設定 VBA セルの操作 背景色の設定 VBA セルの操作 値の代入 VBA始める前の準備 VBAとは? ― ― ― ― ― ― ― ― ― ― → Excel VBA基礎入門もくじ へ戻る