Get the windows username

Tested in Excel 365 (16.8730.2046) 64-bit

 
 
  1. Public Function GetUserName()
  2.     Dim objNet
  3.    
  4.     Set objNet = CreateObject("WScript.NetWork")
  5.     GetUserName = objNet.UserName
  6.     Set objNet = Nothing
  7. End Function

Or the simpler way:

 
 
  1. myName = environ("username")

Add a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.