[015.xls] ' [mjSumple] のコード '■■ ワークシートにセットした情報でログインする ■■ ' Option Explicit Const strPass = "abc" '← 〃 Passを設定(ブック保護で使用したものと同じにして下さい) Sub psFormShow() frmLogin.Show End Sub Sub psLogin() Dim intRet As Integer Dim intCnt As Integer Dim blnID As Boolean blnID = False With frmLogin For intCnt = 15 To 17 If .txtID.Text = Worksheets("sheet1").Cells(intCnt, 5) Then blnID = True Exit For End If Next intCnt If blnID = True And .txtPass = strPass Then ActiveWorkbook.Unprotect (strPass) Sheets("Sheet1").Visible = True Sheets("Sheet1").Select Unload frmLogin Else intRet = MsgBox("ログインに失敗しました", vbExclamation, "エラー") End If End With End Sub ' [frmLogin] のコード Private Sub cmdLogin_Click() Call psLogin End Sub