You are not authorize to use this macro.

Niteshnitesh

New Member
Joined
Nov 9, 2017
Messages
21
Hi all,

I have macro that I want to share with ten people in my team. I have doubt that they can share this macro with another team. I have a excel file in which from A1: A10 are username of ten employees.This file is located in share drive /F:/Temp files/Book1.xlsx. Every one can access this file.I need a code that validate if username exist in that file then it run, if not it give error "You don't have access to use this macro." That file is password protected.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
you can lock the sheet for editing with a password and only give the password to the 10 people you want to run the macro. you can also password protect the entire workbook then only the ones with a password can even open it to see it. two different password one for the workbook and one for the sheet(s)


Might be easier than VBA
 
Upvote 0
You could put something like this at the top of your macro:

Code:
    ValidNames = Array("Huey", "Dewey", "Louie", "Daisy")
    
    If InStr("," & LCase(Join(ValidNames, ",")) & ",", "," & LCase(Application.UserName) & ",") = 0 Then
        MsgBox "Not allowed"
        Exit Sub
    End If
 
Upvote 0

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

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