Formula Errors

Fix Excel #NAME? Error: USERNAME or USER Function Not Recognized

Khadija KhanKhadija Khan Oct 22, 2026 869 views

Question details

The user receives a #NAME? error when attempting to use the =USERNAME() or =USER() functions to automatically insert the current user's name in Excel.

How to Fix Excel #NAME? Error When Using USERNAME or USER Functions
Product
Microsoft Excel
Device & OS
not provided
Scenario
Attempting to automatically extract and display the current user's profile name in a worksheet cell using what is assumed to be a built-in function.
Observed behavior
Excel returns a #NAME? error because the USERNAME and USER functions are not built into the software and cannot be recognized.
Before you start

Ensure you are using the desktop version of Excel for Windows, as the formula workaround relies on local directory paths that may not function correctly in Excel for the Web or macOS.

Solution 1Recommended

Use the INFO Function Workaround Formula

Since Excel lacks a built-in USERNAME function, you can combine the INFO function with text manipulation functions to extract the Windows profile name from your local directory path.

The INFO("DIRECTORY") function returns the current directory path, which typically contains the username in Windows (e.g., C:\Users\Username\Documents). By using LET, SUBSTITUTE, and LEFT functions, you can isolate and extract just the username from this string.

1
Select the target cell

Click on the cell where you want the user's name to be displayed.

2
Enter the formula

Type or paste the following formula into the formula bar: =LET(fullpath,INFO("DIRECTORY"),path,SUBSTITUTE(fullpath,"C:\Users\",""),LEFT(path,FIND("\",path)-1))

3
Execute the formula

Press the Enter key to apply the formula. The cell will now display the extracted Windows user profile name.

Use the INFO Function Workaround Formula
Environment Dependency: This formula extracts the username from the default Windows user directory path. It may return an error or incorrect data on macOS, web versions of Excel, or systems with customized directory setups.
Handle Advanced Formulas in WPS Spreadsheet

Easily Manage Advanced Formulas with WPS Spreadsheet

WPS Office Spreadsheet fully supports advanced text manipulation formulas like LET, SUBSTITUTE, and INFO. It also provides excellent compatibility with Excel macros for custom user functions.

  1. 1. Download WPS Office: Install WPS Office Free from the official website and launch WPS Spreadsheet.
  2. 2. Open your workbook: Open your existing Excel file (.xlsx) directly in WPS Spreadsheet without losing formatting.
  3. 3. Apply the workaround formula: Click on any cell and paste the INFO directory formula to automatically extract the username.
  4. 4. Press Enter: Hit Enter to evaluate the formula seamlessly. WPS Spreadsheet will instantly display the correct username.
Fully compatible with Microsoft Excel formulas and functions (.xlsx format).Supports advanced functions like LET and text manipulation arrays.Built-in error checking to help you quickly identify and resolve #NAME? errors.Lightweight, fast, and completely free to use with a familiar user interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why does =USERNAME() return a #NAME? error?

The #NAME? error occurs because Microsoft Excel does not have a built-in function called USERNAME or USER. When you type a function that does not exist, Excel does not recognize the text and returns a naming error.

Is there a built-in function to get the current user in Excel?

No, Excel does not have a native worksheet function specifically designed to return the current user's name. You must use VBA macros or complex text-extraction formulas based on the INFO function to retrieve this information.

Does the INFO('DIRECTORY') workaround work on Excel for Mac?

No, the specific formula relying on 'C:\Users\' is tailored for Windows environments. On a Mac, the directory structure is different, so the SUBSTITUTE and FIND functions will fail to locate the expected path strings.

How do I generally fix a #NAME? error in Excel?

A #NAME? error usually means there is a typo in the function name, a missing quotation mark around a text string, or an unrecognized named range. Double-check your spelling, ensure all text is enclosed in double quotes, and verify that the function is supported in your version of Excel.