Get and Change User Name with VBA

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on August 19, 2020

This short tutorial will demonstrate how to use the Application.UserName method.

Get and Change Application User Name in VBA

Get User Name

You can use Application.UserName for returning or setting the name of the current user. This is the default name that shows in “macro recorded by”, new comments, “last saved by” etc..

You can display the current user’s name in a message box like this:

MsgBox "Current user is " & Application.UserName

Change User Name

You can change the current user name like this:

Application.UserName = "MonkeyCoder"

If you are interested who is the author of the current workbook, you can get it like this:

UserNameAuthor = ThisWorkbook.BuiltinDocumentProperties("Author")

You can also change it:

ThisWorkbook.BuiltinDocumentProperties("Author") = "ItsMe"

Windows user name can be obtained like this:

UserNameWindows = Environ("UserName")

 

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text

Learn More!


<<Return to VBA Examples

vba-free-addin

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)

Free Download

Return to VBA Code Examples