简体   繁体   中英

VBA Run Macro with Button for Hidden Vba Code

I have a cover sheet with a button the user clicks to generate pdfs. The other sheets are hidden/protected and unprotected by the code. It all works great.

What I would like to do is require a password to view/edit the Macro but allow the user to continue to run the code by clicking the button while the macro is locked.

How can I do this?

ps. I am a rookie at VBA

EDIT: Tools > VBAProject Properties > Protection Doesn't work cus it requires the password to run the macro

Tools > VBAProject Properties > Protection

Password's at the bottom

Ensure that the sub you are trying to run with the button is a Public Sub so that excel can see it still:

Public Sub test()

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM