Option box query

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,047
I have set up an option box and assigned a macro to it, however I have many people who open up this particular spreadsheet but I only want one username to be able to operate this option button......is this possible ?

Thanks

Paul
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Thank you for your reply, what I need it do though is only allow for example John Smith to execute that option button, So if John Smith logs on to his computer he can execute this option button, if Steve Jones logs on I need an error message to come up if he tries to click on the option button ....possible ???
 
Upvote 0
Pauljj said:
Thank you for your reply, what I need it do though is only allow for example John Smith to execute that option button, So if John Smith logs on to his computer he can execute this option button, if Steve Jones logs on I need an error message to come up if he tries to click on the option button ....possible ???

Test for the username in your code and Exit Sub (maybe with a polite message) if it's not the right one.
 
Upvote 0
Sorry, I might be a little dim here but its that part that I cant work out, how to test the user name and if its not to exit the sub with a message ?
 
Upvote 0
Like this?

Code:
If Environ("UserName") <> "John Smith" Then
   MsgBox "Sorry, you can't run this macro."
   Exit Sub
Else
'  Your code goes here
End If
 
Upvote 0
Sorry one last question....if I want this to be available to 2 users, how should I amend your code ?
 
Upvote 0

Forum statistics

Threads
1,224,269
Messages
6,177,568
Members
452,784
Latest member
talippo

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