| 
    
     |  | ▼夜勤担当 さん: >ponponさん
 >ありがとうございます。
 >早速やってみました。問題なく動いています。
 >>「*********」のように表示するには、ユーザーフォームを使い
 >>Textboxを利用するとできると思います。
 >この方法もご伝授いただけませんか?
 
 
 標準モジュールに
 
 Public myPas As Boolean
 Sub step_005()
 Dim sheet1 As Worksheet
 
 Set sheet1 = Worksheets("Sheet1")
 UserForm1.Show
 If myPas Then
 sheet1.Protect Password:="password", _
 AllowFormattingCells:=True
 Else
 MsgBox "パスワードが違います。 残念!"
 Exit Sub
 End If
 End Sub
 
 ユーザーフォームに
 TextBoxを一つとコマンドボタンを一つ貼り付けてください。
 フォームモジュールに
 Private Sub UserForm_Initialize()
 Me.Caption = "パスワード入力"
 Me.TextBox1.PasswordChar = "*"
 
 End Sub
 
 Private Sub CommandButton1_Click()
 myPas = False
 If Me.TextBox1.Text = "password" Then
 myPas = True
 End If
 Unload Me
 End Sub
 
 こんな感じでできると思います。
 
 
 |  |