Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi everyone,
Is there a way to password protect macros especially those written to command buttons. If someone fiddles with a macro, this can mess up the hole work. Thanks Albert |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
you will need to protect the macros themselves so they cannot be
viewed without a password (tools vba project properties protection lock project with password). Then make the macros begin with a line that says : if inputbox("Please enter the password")<"password" then exit sub replace <"password" with < whatever the password you want them to type. |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Totti, Thank you for your reply but I have to admit I am not so familiar
with Macros so if you do not mind I am putting a simple macro here and if possible insert what you told me in it so as I can understand better. The first part I managed, where I inserted the pasword. Thank You Private Sub CommandButton2_Click() Sheets("REPORT").Visible = True Sheets("HOME").Select ActiveWindow.SelectedSheets.Visible = False End Sub Albert "Totti" wrote: you will need to protect the macros themselves so they cannot be viewed without a password (tools vba project properties protection lock project with password). Then make the macros begin with a line that says : if inputbox("Please enter the password")<"password" then exit sub replace <"password" with < whatever the password you want them to type. |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
If you applied a password to your VBA project, then you're done.
Totti was taking it a step further and saying if you don't want someone to use a macro unless they know a specific password (so they cannot click on a button and use it unless they know that button's password), then you can insert the line of code he told you about in the first line of your macro. So if you have a button to run the macro you've shown us here but want to limit the use of that button to just a few people, give them a special password (different from your VBA project password, let's use "hi" for example) and put this in your code. Private Sub CommandButton2_Click() If inputbox("Please enter the password") < "hi" Then Exit Sub Sheets("REPORT").Visible = True Sheets("HOME").Select ActiveWindow.SelectedSheets.Visible = False End Sub -- Please remember to indicate when the post is answered so others can benefit from it later. "albertmb" wrote: Hi Totti, Thank you for your reply but I have to admit I am not so familiar with Macros so if you do not mind I am putting a simple macro here and if possible insert what you told me in it so as I can understand better. The first part I managed, where I inserted the pasword. Thank You Private Sub CommandButton2_Click() Sheets("REPORT").Visible = True Sheets("HOME").Select ActiveWindow.SelectedSheets.Visible = False End Sub Albert "Totti" wrote: you will need to protect the macros themselves so they cannot be viewed without a password (tools vba project properties protection lock project with password). Then make the macros begin with a line that says : if inputbox("Please enter the password")<"password" then exit sub replace <"password" with < whatever the password you want them to type. |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thank You KC for the explanation. I realy appreciate it. May I take this
opportunity to wish you all a most prosperous new year. Albert "KC Rippstein" wrote: If you applied a password to your VBA project, then you're done. Totti was taking it a step further and saying if you don't want someone to use a macro unless they know a specific password (so they cannot click on a button and use it unless they know that button's password), then you can insert the line of code he told you about in the first line of your macro. So if you have a button to run the macro you've shown us here but want to limit the use of that button to just a few people, give them a special password (different from your VBA project password, let's use "hi" for example) and put this in your code. Private Sub CommandButton2_Click() If inputbox("Please enter the password") < "hi" Then Exit Sub Sheets("REPORT").Visible = True Sheets("HOME").Select ActiveWindow.SelectedSheets.Visible = False End Sub -- Please remember to indicate when the post is answered so others can benefit from it later. "albertmb" wrote: Hi Totti, Thank you for your reply but I have to admit I am not so familiar with Macros so if you do not mind I am putting a simple macro here and if possible insert what you told me in it so as I can understand better. The first part I managed, where I inserted the pasword. Thank You Private Sub CommandButton2_Click() Sheets("REPORT").Visible = True Sheets("HOME").Select ActiveWindow.SelectedSheets.Visible = False End Sub Albert "Totti" wrote: you will need to protect the macros themselves so they cannot be viewed without a password (tools vba project properties protection lock project with password). Then make the macros begin with a line that says : if inputbox("Please enter the password")<"password" then exit sub replace <"password" with < whatever the password you want them to type. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Protection macro | Excel Discussion (Misc queries) | |||
Macro and row protection | Excel Discussion (Misc queries) | |||
Protection Macro | Excel Discussion (Misc queries) | |||
Macro Protection | New Users to Excel | |||
macro for protection | Excel Discussion (Misc queries) |