Disable All Macros in Workbook if user not authorized

Negi1984

Board Regular
Joined
May 6, 2011
Messages
198
Hi All,

I have a workbook where around 35 macros created to complete and reconcile multiple tasks.

Now I want macro can only be run by 3 users like user A & user B & user C. Apart from this nobody can able to run any macros in the workbook.

Can anybody suggest me, how to solve this issue.

Regards,
Rajender
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Add password (and/or even a login) to all macros, with InputBox.
Maybe even setup a Forms.
 
Upvote 0
Hi Most,

Thanks for the suggestion. If not any alternative to add one more macro instead of updating all existing macros?
 
Upvote 0
I'm not sure I completely understand your question. No, there are no built in security feature in Excel which will solve your requirement.
 
Upvote 0
The only suggestion I have is to make all your modules private so they don't show in the window.

Then create a new macro with password input box > which if validated could pop up a userform or prompt to run others macros.
 
Upvote 0
Add a password to the sheet and an Inputbox for the required users "password"
AND simply password protect the VBE !!
While it can be broken, you average user generally won't be able to !!
Deleting macros IS possible but I wouldn't advise it !!
 
Upvote 0
Hi,

Thank you , I am think now to protect module and hide from preview and in workbook open event write a code which will hide all objects from the workbook, if user is not authorized.

Could you please suggest , where I need to do modification in below code and hide all objects in workbook while open workbook.

Code:
Function test()
test = False
'Pass the user to the checking function
If allowed(Environ("username")) Then
    test = True
    Else: MsgBox ("You can't use macros here")
End If
End Function


--------------------------------------------------
Public Function allowed(ByRef TF As String) As Boolean
    Dim arr As Variant
    arr = Array("name1", "name2", "name3")
    For Each Item In arr
        If Item = TF Then
        allowed = True
        Exit Function
        Else: allowed = False
        End If
    Next

End Function
 
Upvote 0

Forum statistics

Threads
1,216,604
Messages
6,131,697
Members
449,666
Latest member
Tommy2Tables365

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top