Hi Faisal,
Try adding the following to the code for your command button:
Private Sub CommandButton1_Click()
Dim InitialFilterValue As String
InitialFilterValue = InputBox("Please enter the password.", "PASSWORD
REQUIRED")
'To end sub if "cancel" was pressed or passowrd is wrong, sourced from
_
http://www.excelforum.com/showthread.php?t=466059&highlight=vbcancel+input
&
http://vb.mvps.org/tips/varptr.asp
If StrPtr(InitialFilterValue) = 0 Then
Exit Sub
Else
If InitialFilterValue = "secret" Then
Else
Exit Sub
End If
End If
'enter your code here
End Sub
This is just a starting point as there are ways of making it loop until
the correct password is entered or only allowing 3 tries etc.
NB: To prevent anyone opening the VB Editor to identify the password as
"secret" you will need to lock the VB Project. To do this right click on
a module/sheet code in the VBE & select VBA Project Properties - Lock
for Viewing.
hth
Rob Brockett
NZ
Always learning & the best way to learn is to experience...