Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default PASSWORD PROMPTING CODE

I have assigned a macro code to a command button in Excel. I need a
macro code to add to my original code that will prompt any user that
pushes the button to enter a password before the code assigned to the
button executes.
Any assistance will be appreciated.Thanks!

Jay Dean.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default PASSWORD PROMPTING CODE

Jay, how about something like this

Sub PassWord_for_Macro()
'must lock VBA project so you can't see the password in it
Dim MyStr1 As String, MyStr2 As String
With ActiveSheet
MyStr2 = ("123") 'change to your password
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then
'*******your code here********
Else
MsgBox ("Password Does Not Match, Access Denied")
End If
End With
End Sub

--
Paul B
Always backup your data before trying something new
Using Excel 2000 & 97
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **
"Jay Dean" wrote in message
om...
I have assigned a macro code to a command button in Excel. I need a
macro code to add to my original code that will prompt any user that
pushes the button to enter a password before the code assigned to the
button executes.
Any assistance will be appreciated.Thanks!

Jay Dean.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default PASSWORD PROMPTING CODE

Jay,

This code uses a simple InputBox to query the user for a password.

Troy


Sub RequestPassword()

Dim sReply As String

sReply = Application.InputBox( _
Prompt:="Please enter the password", _
Title:="Password Required", _
Type:=2)

If sReply = "thePassword" Then
'''Run the password protected code.
MsgBox sReply & " is the correct password"

Else
'''Do not run the password protected code.
MsgBox "Sorry, incorrect password"
End If

End Sub



"Jay Dean" wrote in message
om...
I have assigned a macro code to a command button in Excel. I need a
macro code to add to my original code that will prompt any user that
pushes the button to enter a password before the code assigned to the
button executes.
Any assistance will be appreciated.Thanks!

Jay Dean.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default PASSWORD PROMPTING CODE

Thank you very much. It worked beautifully !!

Jay Dean

"TroyW" wrote in message ...
Jay,

This code uses a simple InputBox to query the user for a password.

Troy


Sub RequestPassword()

Dim sReply As String

sReply = Application.InputBox( _
Prompt:="Please enter the password", _
Title:="Password Required", _
Type:=2)

If sReply = "thePassword" Then
'''Run the password protected code.
MsgBox sReply & " is the correct password"

Else
'''Do not run the password protected code.
MsgBox "Sorry, incorrect password"
End If

End Sub



"Jay Dean" wrote in message
om...
I have assigned a macro code to a command button in Excel. I need a
macro code to add to my original code that will prompt any user that
pushes the button to enter a password before the code assigned to the
button executes.
Any assistance will be appreciated.Thanks!

Jay Dean.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
remove password on VBA code Tom Excel Discussion (Misc queries) 1 February 13th 10 06:36 AM
Put Password Protection in Code Connie Excel Discussion (Misc queries) 3 October 25th 06 08:06 PM
Include a password in VB code. GA Excel Discussion (Misc queries) 6 March 23rd 06 07:36 AM
How to see macro code of a password protected macro without a password? Dmitry Kopnichev Excel Worksheet Functions 5 October 27th 05 09:57 AM
password protect vba code greg Excel Discussion (Misc queries) 3 December 8th 04 04:03 PM


All times are GMT +1. The time now is 07:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"