+ Reply to Thread
Results 1 to 10 of 10

Environ = Username

  1. #1
    Forum Contributor
    Join Date
    03-20-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    200

    Environ = Username

    Hi

    Using

    Public Function UserName()
    UserName = Environ$("UserName")
    End Function

    then

    Range("C2").Select
    ActiveCell.FormulaR1C1 = "=UserName()"

    Is it possible to display the name with Capital on the first name Capital on the surname, with a space in the middle?
    thanks

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Environ = Username

    How is the username currently displayed - what delimits the first / last names?

    If, for example, the name is in the format john.smith then you could use:

    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Environ = Username

    Please post code in [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags.

    I don't know how your User name looks like, this is an assumption.

    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  4. #4
    Forum Contributor
    Join Date
    03-20-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Environ = Username

    Thanks

    sorry it displays it

    tomsmith
    davidjones
    rachelsmith
    johnsmith

    etc etc

    the above doesnt appear to work.
    thanks for the reply

  5. #5
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Environ = Username

    Ok, obviously it wouldn't work.

    How are you going to differentiate the first name and surname?

    No macro would be smart enough to do that (I think), unless you have a predefined list of names.

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Environ = Username

    Quote Originally Posted by papasmurfuo9 View Post
    it displays it

    tomsmith
    davidjones
    rachelsmith
    johnsmith

    etc etc
    Okay, so how will any formula or code identify where the first name ends and the last name begins?

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Environ = Username


    Hi,

    with no separator, can't split firstname and name ‼

    You have to build a translate table …

  8. #8
    Forum Contributor
    Join Date
    03-20-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Environ = Username

    Cheers
    wasnt sure how environ username works, or how it pulled it through
    but thanks for the confirmation

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Environ = Username

    application.username may (or may not) be worth considering too, depending on your system policies on user naming.

  10. #10
    Forum Contributor
    Join Date
    03-20-2013
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Environ = Username

    Cheers
    i will use the following

    Please Login or Register  to view this content.
    then build a table with all the users with a lookup, using iferror to display the username with no space/capitals if they aint in the table
    thanks

+ 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. Parse first name & surname from Windows logon name (Environ("UserName")
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-15-2013, 08:08 PM
  2. [SOLVED] Environ Username issue
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2013, 11:55 AM
  3. [SOLVED] Vlookup Environ ("username") to get proper name and allocate protection
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-04-2012, 04:31 AM
  4. Difference between Environ("USERNAME") and Environ$("USERNAME")
    By ron2k_1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-04-2011, 11:15 AM
  5. Including Environ Username in Cell
    By swieduwi in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-30-2006, 11:43 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