+ Reply to Thread
Results 1 to 4 of 4

Issue with changing user names - help with ENVIRON()

  1. #1
    Registered User
    Join Date
    10-30-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    14

    Red face Issue with changing user names - help with ENVIRON()

    Hey everybody!!

    Thanks for your interest. Let me explain my end result first...

    I have three computers running Windows 8.1 Pro x64 with Office 2013 on two of them, and Office 2010 on the third one. They all have Microsoft SkyDrive/OneDrive installed - all using the same SkyDrive/OneDrive credentials. The Windows credentials are all different, and therefore C:\Users\username\ is a variable. I have an Excel worksheet in C:\Users\username\SkyDrive\games\ called calculator.xlsx. In the same directory as calculator.xlsx, I have a "data" folder, and within the data folder is a giant hierarchy of Excel files organized in folders. This complex collection of data in the form of Excel files is updated nightly by one of the three computers I mentioned above using a web-browser data scraping tool. It updates hundreds of these files in the "data" folder every night. I built the calculator to use functions which references data in specific cells of specific workbooks deep within the "data" folder. It works GREAT on one computer. However, when I launch the calculator Workbook on one of my other two computers, none of the links work because it can't find the path (the username is different). The calculator doesn't work.

    GOAL: I want my calculator spreadsheet to reference the environment variable for current user. I know it can't do that, so I need some sort of VBA code that'll help me.

    Here's what my current reference to other data looks like from a cell in my calculator: ='C:\Users\photodotexe\OneDrive\games\data\standard\exchange rates\[standardexchange.xlsx]Table 1'!B3. This works great on the computer that I log in as "photodotexe" on. But what about the computer I log in with "Mark" on? Doesn't work...

    I am experiencing difficulty using the ENVIRON() VBA function. I mean, I may be doing it wrong because I don't know VBA at all. But, will that even help me in my case?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,426

    Re: Issue with changing user names - help with ENVIRON()

    Maybe this will help:

    http://www.excelforum.com/tips-and-t...excel-vba.html


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,426

    Re: Issue with changing user names - help with ENVIRON()

    Is this resolved?

  4. #4
    Registered User
    Join Date
    10-30-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    14

    Re: Issue with changing user names - help with ENVIRON()

    Almost.. I really appreciate the input! I managed to add a new module with the following code...

    Function UserName()
    UserName = Environ("username")

    End Function

    This allows me to use =UserName() to pull the current username. However, I'm trying to put that in a path. Like C:\Users\UserName()\SkyDrive\ doesn't work. I'm still researching this - but I'm open to suggestion!

+ 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] Environ Username issue
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2013, 11:55 AM
  2. Changing names to User ID numbers
    By stoudty in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-12-2012, 08:00 AM
  3. [SOLVED] how to user environ in textbox field of userform
    By Ignesh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-24-2012, 05:40 AM
  4. Replies: 0
    Last Post: 12-14-2011, 02:28 PM
  5. Environ user tracking
    By geraintathomas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-11-2006, 08:26 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