+ Reply to Thread
Results 1 to 11 of 11

VBA - Run only for specific users

  1. #1
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    VBA - Run only for specific users

    Hi All,

    I want to run an event for specific user. In this case, only John Doe should be able to run this command. It works fine if i put john doe in there and i get the MSGBOX since my windows log in is not John doe. But when I put my windows login there (and only I can run it), i dont get any msgbox or the rest of the command does not run....anyone can help me what I am missing? code in question is in red

    Thanks all

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: VBA - Run only for specific users

    Exit Sub should be within the If End If condition HTH
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  3. #3
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA - Run only for specific users

    thanks for the reply, i am getting compile error: End If without block If. Do i need to user Goto? to direct it to the first event for the user who has the right?

  4. #4
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA - Run only for specific users

    thanks for your suggestion, im a beginner so i wrote it this way and it is working.

    Please Login or Register  to view this content.
    I got this solved, but how would i do it if i want to name multiple users whos have the rights?

  5. #5
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: VBA - Run only for specific users

    Hi honger,

    Try this for your initial code:

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  6. #6
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA - Run only for specific users

    perfect robert, your way works perfectly and i didnt have to rely on my clumsy method.

    do you happen to know how i can name more than just one person?

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: VBA - Run only for specific users

    do you happen to know how i can name more than just one person?
    Maybe - the solution will be dependent on how may names we're talking about. Let me know that and I'll see if I can code something.

    Robert

  8. #8
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA - Run only for specific users

    3 people.....but i may have to add users down the line if the responsbility is given to more people.

    Currentlyi have 25 in our group, but i only want 3 of them to have ability to run this. But i may have to give other the rights as well down the line.

    But i will take a solution for just three people now!! thanks
    Last edited by honger; 06-04-2014 at 12:59 AM.

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: VBA - Run only for specific users

    OK - for a dataset of that size use this (just change the names to suit):

    Please Login or Register  to view this content.
    Just add the names you need to the varMyArray variable.

    HTH

    Robert

  10. #10
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA - Run only for specific users

    beautiful!
    i have a long way to go to do these on my own, thanks so much for all the help guys

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: VBA - Run only for specific users

    thanks so much for all the help guys
    You're welcome

    If you could mark the thread as solved it would be appreciated.

    Regards,

    Robert

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Hiding tabs from specific Users!!
    By jsuarez199 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 04-16-2013, 06:39 AM
  2. Replies: 2
    Last Post: 12-15-2011, 12:13 PM
  3. Hide sheets for specific users
    By Robert1986 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2007, 06:11 AM
  4. share specific columns with other users
    By BeckyS in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-16-2006, 04:35 PM
  5. [SOLVED] I need to control how users sort in a specific excell worksheet
    By Kim Melkane in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-31-2005, 09:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1