Restrict Use of a macro

T

Tonso

I have a macro in an XL2007 workbook that copies and pastes and formats data in the workbook. Others look at the data but I were prefer they not be able to invoke the macro as it could cause inaccuracies in the workbook for a user not familiar the macro or the data entry. Is there a way I can have an input box or something open when the macro is first invoked that asks for a password, and exits the macro if the correct password is not entered? Or is there a better way to accomplish what I want?

Thanks!

Tonso
 
G

GS

I have a macro in an XL2007 workbook that copies and pastes and
formats data in the workbook. Others look at the data but I were
prefer they not be able to invoke the macro as it could cause
inaccuracies in the workbook for a user not familiar the macro or the
data entry. Is there a way I can have an input box or something open
when the macro is first invoked that asks for a password, and exits
the macro if the correct password is not entered? Or is there a
better way to accomplish what I want?

Thanks!

Tonso

Post your code!

Assuming your VBA project is locked, use the InputBox function to
request the password, exit the macro if incorrect...

Dim vAns As Variant
Const sPWD$ = "password"

vAns = InputBox("Enter the password")
If Not vAns = sPWD Then Exit Sub 'or Function

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
T

Tonso

I have a macro in an XL2007 workbook that copies and pastes and formats data in the workbook. Others look at the data but I were prefer they not be able to invoke the macro as it could cause inaccuracies in the workbook fora user not familiar the macro or the data entry. Is there a way I can havean input box or something open when the macro is first invoked that asks for a password, and exits the macro if the correct password is not entered? Or is there a better way to accomplish what I want? Thanks! Tonso

Garry,

Thanks!

Tonso
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top