Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Password on Macro Button

Is it possible to have a macro assigned to a macro button that when the
button is selected it will ask for a password before the macro will run?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Password on Macro Button

How about asking first thing in the macro:

Option Explicit
Sub Testme()
dim pwd as password
'more declarations

'before you do anything

pwd = inputbox(Prompt:="What's the password, Kenny?")

if pwd = "topSeCreT" then
'keep going
else
'nope, get out
exit sub
end if

'more code here

End sub

You may want to protect the project to make it a little more difficult for most
people to see the password in your code.

Select your project in the VBE
Tools|VBAProject|Protection tab
Give it a memorable password

Note that there are inexpensive project password breakers available. You won't
stop all, but you'll stop most.




scuba wrote:

Is it possible to have a macro assigned to a macro button that when the
button is selected it will ask for a password before the macro will run?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 209
Default Password on Macro Button

A VERY simple password [password = HELLO] that is VERY unprotected would be...
'/========================================/
Sub MyMacroButton()
If SimplePassword(InputBox("Enter Password: ")) Then
'put code here
Else
Exit Sub
End If
End Sub
'/========================================/
Private Function SimplePassword(strAnswer As String) As Boolean
If UCase(strAnswer) = "HELLO" Then
SimplePassword = True
End If
End Function
'/========================================/
--
Hope this helps.
Thanks in advance for your feedback.
Gary Brown


"scuba" wrote:

Is it possible to have a macro assigned to a macro button that when the
button is selected it will ask for a password before the macro will run?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Password on Macro Button

Thank you to both of you for your help. I got it to work.
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
Using Macro to sort without clicking on macro button dd Excel Discussion (Misc queries) 3 May 3rd 07 06:00 PM
password protect the button in Excel? cfman Excel Discussion (Misc queries) 3 March 2nd 07 09:06 PM
Password restricted single macro and button michaelberrier Excel Discussion (Misc queries) 1 June 19th 06 10:38 PM
use macro button to run macro in protected sheet earl Excel Discussion (Misc queries) 3 February 26th 06 10:21 PM
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


All times are GMT +1. The time now is 07:25 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"