π Excel Formula Spotlight: First Name with Random Suffix Generator


If you're working in Excel and need a quick way to generate a custom identifier using a person's first name followed by a random number, this formula is a perfect solution.
π― What the Formula Does
=IF(ISNUMBER(SEARCH(" ", B2)), TEXTBEFORE(B2, " "), B2) & "@" & RANDBETWEEN(1000,99999)
It dynamically:
Extracts the first name from a full name in cell
B2
,Appends an
"@"
symbol,Adds a random number (between 1000 and 99999).
π Real-World Examples
Full Name (B2) | Generated Output |
John Doe | John@27483 |
Asha | Asha@83917 |
Each time the sheet recalculates, the random number updates β great for generating unique, non-sensitive identifiers or temporary usernames.
π§ How It Works
SEARCH(" ", B2)
β Looks for a space character in the cell (to check if there's a full name).ISNUMBER(...)
β Returns TRUE if a space exists, meaning thereβs a full name.TEXTBEFORE(B2, " ")
β Extracts the first name from the full name.B2
β If no space is found (i.e., just a first name), returns the whole value."@" & RANDBETWEEN(1000,99999)
β Adds an@
and a random number between 1000 and 99999.
π οΈ Use Cases
Quickly generate test usernames like
Asha@54321
Create non-personal unique IDs for events, forms, or demos
Lightweight way to pseudo-anonymize user data in Excel
π Tips
Want a fixed ID? Copy the result and use Paste Special β Values to lock it in.
You can increase randomness by extending the number range (e.g.,
100000
to999999
).
Thanks for reading.
Subscribe to my newsletter
Read articles from Vishal Mathur directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Vishal Mathur
Vishal Mathur
With over 9 years of experience as in IT, I have led technology operations across diverse industries, ensuring robust IT infrastructure, network security, and team development. My expertise spans managing IT infrastructure & operations, IT policy, and backup/disaster recovery. My expertise also includes IT asset management, Google Workspace & Office 365, endpoint security, DLP, and cross-platform systems (Windows/Linux/Mac OS) etc. Additionally, I hold certifications in Google IT Support, CCNA, and IBM Cybersecurity, reinforcing my commitment to continuous learning and delivering robust technology solutions. Thank you for your time and consideration. Best regards, Vishal Mathur