+ Reply to Thread
Results 1 to 6 of 6

Macro to run if only folder found...

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Macro to run if only folder found...

    Hi,

    I would like to know how is it possible to only run a macro with IF command if a path is found in a computer. My desktop user is example, jc855, and my coworker is jc886.
    I would like to start the IF command such as, if
    C:\Users\jc855 & C:\Users\jc886 found, then keep going, otherwise, message box : "You are not authorize to run this macro".
    By having this path, people will be able to download this macro but the access is only granted if their user is added thru the VBA. (which only me can access to edit it).

    Thanks for help.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2509 Win 11
    Posts
    25,002

    Re: Macro to run if only folder found...

    How about testing for the username, ie

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Macro to run if only folder found...

    Something like:

    Please Login or Register  to view this content.
    Gary's Student

  4. #4
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Macro to run if only folder found...

    Quote Originally Posted by alansidman View Post
    How about testing for the username, ie

    Please Login or Register  to view this content.
    How this Environ username work? Which username does it pull from?

    Thanks.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2509 Win 11
    Posts
    25,002

    Re: Macro to run if only folder found...

    Environ("UserName") pulls the Windows username for the person logged into the particular machine.

    Here a couple of other environmental functions you might find useful

    http://datapigtechnologies.com/blog/...omainusername/

  6. #6
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Macro to run if only folder found...

    Nice one!! Thanks a lot!

+ 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. Replies: 1
    Last Post: 03-12-2013, 04:45 AM
  2. Macro to open file if found in a folder or any subfolders
    By beze12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2012, 02:27 AM
  3. [SOLVED] Macro to loop in folder and then open the workbook with found value
    By Jey Robbins in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2012, 12:10 PM
  4. Add File Sizes for Files Found in a Specified Folder
    By R_S_6 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2010, 07:52 AM
  5. Save WB from reference found in cell D1 to specific folder
    By Annette in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2006, 12:35 PM

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