Excel Guides

Generating Random Strings of Characters in Excel

There are a few ways to generate random strings of characters in Excel. One way is to use the RANDBETWEEN function. This function takes two arguments, a bottom and top number, and returns a random number between those two numbers. So, if we wanted to generate a random string of characters that was five characters long, we could use the following formula:

=RANDBETWEEN(0,9)&RANDBETWEEN(0,9)&RANDBETWEEN(0,9)&RANDBETWEEN(0,9)&RANDBETWEEN(0,9)

This would give us a string of five random numbers. If we wanted letters instead of numbers, we could use the CHAR function. The CHAR function takes a number and returns the character that corresponds to that number. So, if we wanted to generate a random string of letters that was five characters long, we could use the following formula:

=CHAR(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))

This would give us a string of five random uppercase letters. If we wanted lowercase letters instead of uppercase letters, we could use the following formula:

=CHAR(RANDBETWEEN(97,122))&CHAR(RANDBETWEEN(97,122))&CHAR(RANDBETWEEN(97,122))&CHAR(RANDBETWEEN(97,122))&CHAR(RANDBETWEEN(97,122))

If we wanted a mix of upper and lower case letters, we could use the following formula:

=CHAR((ROUNDUP((ROW()-1)/26)+64)*SIGN((MOD((ROW()-1),26)-13)))&CHAR((MOD((ROW()-1),26)+65)*SIGN((MOD((ROW()-1),26)-13)))

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.