Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default protecting a macro button

I have a spreadsheet set up with a few macro buttons and I was looking for a
way to protect those buttons so that only certain users would be able to push
them.

Is there any way to do this?

Thanks so much!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default protecting a macro button

mydogpeanut, you could ask for a password to run the macro, something like
this

Sub PassWord_To_Run_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") 'This is the password and it is CASE sensitive
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then

'your code here

Else
MsgBox ("Access Denied")
End If
End With
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"mydogpeanut" wrote in message
...
I have a spreadsheet set up with a few macro buttons and I was looking for
a
way to protect those buttons so that only certain users would be able to
push
them.

Is there any way to do this?

Thanks so much!!!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default protecting a macro button

Paul can't thank you enough!! This worked GREAT!!!!!

thanks again!!!

"Paul B" wrote:

mydogpeanut, you could ask for a password to run the macro, something like
this

Sub PassWord_To_Run_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") 'This is the password and it is CASE sensitive
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then

'your code here

Else
MsgBox ("Access Denied")
End If
End With
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"mydogpeanut" wrote in message
...
I have a spreadsheet set up with a few macro buttons and I was looking for
a
way to protect those buttons so that only certain users would be able to
push
them.

Is there any way to do this?

Thanks so much!!!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default protecting a macro button

Your welcome
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"mydogpeanut" wrote in message
...
Paul can't thank you enough!! This worked GREAT!!!!!

thanks again!!!

"Paul B" wrote:

mydogpeanut, you could ask for a password to run the macro, something
like
this

Sub PassWord_To_Run_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") 'This is the password and it is CASE sensitive
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then

'your code here

Else
MsgBox ("Access Denied")
End If
End With
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"mydogpeanut" wrote in message
...
I have a spreadsheet set up with a few macro buttons and I was looking
for
a
way to protect those buttons so that only certain users would be able
to
push
them.

Is there any way to do this?

Thanks so much!!!






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default protecting a macro button

Anthoer Question...

How do I hide the password in the Macro? So if someone is looking or trying
to look at the macro they do not see the password?

Also is there anyway that when the box pops up asking for the password to
make it so the password doesn't show while typing it in?

Thanks so much for any and all help

"Paul B" wrote:

Your welcome
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"mydogpeanut" wrote in message
...
Paul can't thank you enough!! This worked GREAT!!!!!

thanks again!!!

"Paul B" wrote:

mydogpeanut, you could ask for a password to run the macro, something
like
this

Sub PassWord_To_Run_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") 'This is the password and it is CASE sensitive
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then

'your code here

Else
MsgBox ("Access Denied")
End If
End With
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"mydogpeanut" wrote in message
...
I have a spreadsheet set up with a few macro buttons and I was looking
for
a
way to protect those buttons so that only certain users would be able
to
push
them.

Is there any way to do this?

Thanks so much!!!








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default protecting a macro button

This was commented in the macro "'must lock VBA project so you can't see the
password in it"

To protect the VBA project, from your workbook right-click the workbook's
icon and pick View Code. This icon is at the top-left of the spreadsheet
this will open the VBA editor, in Project Explorer right click on your
workbook name, if you don't see it press CTRL + r to open the Project
Explorer then select VBA project properties, protection, check lock project
for viewing and set a password. Press Alt and Q to close this window and go
back to your workbook and save and close the file. Be aware that this
password can be broken by third party software.

If you don't want to see what is entered in the box you will have to create
a userform with a textbox on it and set the PasswordChar property to *
and a button to validate the password that was put in, more work but it can
be done.


"mydogpeanut" wrote in message
...
Anthoer Question...

How do I hide the password in the Macro? So if someone is looking or
trying
to look at the macro they do not see the password?

Also is there anyway that when the box pops up asking for the password to
make it so the password doesn't show while typing it in?

Thanks so much for any and all help

"Paul B" wrote:

Your welcome
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"mydogpeanut" wrote in message
...
Paul can't thank you enough!! This worked GREAT!!!!!

thanks again!!!

"Paul B" wrote:

mydogpeanut, you could ask for a password to run the macro, something
like
this

Sub PassWord_To_Run_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") 'This is the password and it is CASE sensitive
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then

'your code here

Else
MsgBox ("Access Denied")
End If
End With
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from
it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"mydogpeanut" wrote in message
...
I have a spreadsheet set up with a few macro buttons and I was
looking
for
a
way to protect those buttons so that only certain users would be
able
to
push
them.

Is there any way to do this?

Thanks so much!!!








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default protecting a macro button

Paul my hero once again.

Thanks so much!

"Paul B" wrote:

This was commented in the macro "'must lock VBA project so you can't see the
password in it"

To protect the VBA project, from your workbook right-click the workbook's
icon and pick View Code. This icon is at the top-left of the spreadsheet
this will open the VBA editor, in Project Explorer right click on your
workbook name, if you don't see it press CTRL + r to open the Project
Explorer then select VBA project properties, protection, check lock project
for viewing and set a password. Press Alt and Q to close this window and go
back to your workbook and save and close the file. Be aware that this
password can be broken by third party software.

If you don't want to see what is entered in the box you will have to create
a userform with a textbox on it and set the PasswordChar property to *
and a button to validate the password that was put in, more work but it can
be done.


"mydogpeanut" wrote in message
...
Anthoer Question...

How do I hide the password in the Macro? So if someone is looking or
trying
to look at the macro they do not see the password?

Also is there anyway that when the box pops up asking for the password to
make it so the password doesn't show while typing it in?

Thanks so much for any and all help

"Paul B" wrote:

Your welcome
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"mydogpeanut" wrote in message
...
Paul can't thank you enough!! This worked GREAT!!!!!

thanks again!!!

"Paul B" wrote:

mydogpeanut, you could ask for a password to run the macro, something
like
this

Sub PassWord_To_Run_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") 'This is the password and it is CASE sensitive
MyStr1 = InputBox("Password Is Required To Run this Macro ")
If MyStr1 = MyStr2 Then

'your code here

Else
MsgBox ("Access Denied")
End If
End With
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from
it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"mydogpeanut" wrote in message
...
I have a spreadsheet set up with a few macro buttons and I was
looking
for
a
way to protect those buttons so that only certain users would be
able
to
push
them.

Is there any way to do this?

Thanks so much!!!









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
Protecting a worksheet which has button controlled macros Clinton Walker Excel Programming 0 September 21st 06 04:48 AM
Protecting a worksheet which has button controlled macros Clinton Walker Excel Discussion (Misc queries) 0 September 8th 06 03:21 AM
How can I use the tab button after protecting the worksheet? Joanne, BC Excel Worksheet Functions 2 December 6th 05 09:44 PM
Pause macro, add form button to sheet, continue macro when button clicked! Flystar[_15_] Excel Programming 1 May 26th 04 09:45 AM
Protecting a macro Richard Bishop Excel Programming 3 February 25th 04 12:00 PM


All times are GMT +1. The time now is 04:25 PM.

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"