| 
    
     |  | ▼プリ さん: >arajin さんありがとうございます。
 >見事に出来ました。
 >ActiveCell.Value = 12 は、2回記述されてますが、1回にすることは出来ますか?
 
 そんなのは、自分で工夫して欲しいところでっせ。
 
 そういうのは、もうコーディング者の好みだと思いますけどね。
 
 Private Sub CommandButton1_Click()
 Dim ret As Variant
 Dim f As Boolean
 With ActiveSheet
 f = .ProtectContents
 If f Then
 ret = Application.InputBox("パスワードをどうぞ", Title:="パスワード入力", Type:=2)
 If VarType(ret) = vbBoolean Then Exit Sub
 On Error GoTo ErrHndl
 .Unprotect ret
 On Error GoTo 0
 End If
 ActiveCell.Value = 12
 If f Then .Protect ret
 End With
 Exit Sub
 ErrHndl:
 MsgBox Err.Description, vbExclamation
 End Sub
 
 とかですかね〜。
 
 まあ、ご自分の好みにあう方法を探ってみて下さいよ。
 
 |  |