joanne您好: 您可以利用錄製巨集的方式,將Excel資料驗證操作一遍,底下的VBA是我在儲存格A1設定只可以輸入1-5的數字.Sub Macro1()'' Macro1 Macro' tsaimh 在 2012/1/18 錄製的巨集'' With Selection.Validation .Delete .Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _ Operator:=xlBetween, Formula1:="1", Formula2:="5" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .IMEMode = xlIMEModeNoControl .ShowInput = True .ShowError = True End WithEnd Sub其它的儲存格如果執行這個巨集,也會有一樣的資料驗證.
|