When working with Excel, I often have a need to generate random data for various purposes.
One interesting task that comes to mind is generating random letters in Excel.
This can be helpful for creating sample text, testing formulas, or even generating security keys and passwords.
Although Excel has two worksheet functions, RAND and RANDBETWEEN, meant for generating random numbers, it does not have specific functions for generating random alphabet letters.
But there is a simple workaround that will allow us to quickly generate a list of random letters or even a string of letters.
In this tutorial, I will show you two workarounds to generate random letters in Excel. I have also covered a method that shows how to generate a string of random letters in Excel.
Generate Random Letters in Excel (With Duplicates)
Let’s cover the following:
- How to Generate Random Letters in Uppercase
- How to Generate Random Letters in Lowercase
The RANDBETWEEN function produces a random number between specified numbers.
The CHAR function returns the letter identified by the code number.
Therefore, we can use a formula where the numbers produced by the RANDBETWEEN function are used as arguments by the CHAR function to generate random letters in either uppercase or lowercase.
How to Generate Random Letters in Uppercase
I want to generate 15 random letters in uppercase using a formula combining the CHAR and RANDBETWEEN functions.
Here is how I do it:
- Select cell A1 and enter the following formula:
=CHAR(RANDBETWEEN(65,90))
- Drag the Fill Handle to copy the formula down the column to cell A16.
Fifteen random letters in uppercase are generated.
Note: The volatile formula will generate new random letters each time you recalculate the worksheet. If you want to freeze the values, copy and paste the cells as values.
Explanation of the formula
=CHAR(RANDBETWEEN(65,90))
This formula uses the RANDBETWEEN function to generate random numbers between and including 65 and 90 and then uses the CHAR function to convert the numbers to letters in uppercase.
Note that 65 is the ASCII code for “A,” and 90 is the ASCII code for “Z.
Also read: How to Change Uppercase to Lowercase in Excel
Handling Duplicate Letters
Notice that the formula combining the CHAR and RANDBETWEEN functions returned a couple of duplicate letters, as seen below:
If you have no problem with duplicate values, the formula is the most convenient way to generate random letters in uppercase in Excel.
However, if you do not want duplicate values in the dataset, you can remove them using Excel’s built-in Remove Duplicates feature.
Here is how to do this:
- Freeze the dataset by copying it and pasting it as values.
- Select the dataset.
- On the Data tab, on the Data Tools group, click the Remove Duplicates button.
- On the Remove Duplicates dialog box, ensure the target column is selected and click OK.
Excel sends a message box to the screen, showing the number of duplicate values found and removed and the number of remaining unique values.
Check the dataset to confirm that the duplicate values have been removed and that all the remaining letters are unique.
Also read: How to Generate Random Numbers in Excel (Without Duplicates)
How to Generate Random Letters in Lowercase
To generate, for example, fifteen random letters in lowercase, we follow the steps below:
- Select cell A1 and enter the below formula:
=CHAR(RANDBETWEEN(97,122))
- Copy the formula down the column by dragging the Fill Handle to cell A16.
Note that the formula is volatile and will generate new random letters each time you recalculate the worksheet. If you want to freeze the values, copy and paste the cells as values.
Notice that the formula returned some duplicate letters, as seen below:
If you are OK with duplicate values, the formula is the most convenient way to generate random letters in lowercase in Excel.
However, suppose you do not want duplicate values in the dataset. In that case, you can remove them using Excel’s built-in Remove Duplicates feature, as described in this tutorial’s “Handling Duplicate Letters” section.
Explanation of the formula
=CHAR(RANDBETWEEN(97,122))
This formula uses the RANDBETWEEN function to generate random numbers between and including 97 and 122 and then uses the CHAR function to convert the numbers to letters in lowercase.
Note that 97 is the ASCII code for the letter “a,” and 122 is the ASCII code for the letter “z.”
Also read: How to Extract Number from Text in Excel (Beginning, End, or Middle)
How to Generate a String of Random Letters in Excel
You can generate a string of random letters in Excel, not just individual ones.
Let’s look at the following:
- How to generate a string of random letters in uppercase.
- How to create a string of random letters in uppercase and lowercase.
Generate a String of Random Letters (Uppercase)
We use the steps below to generate a string of five letters in uppercase:
- Select the cell to which you want to add a string of random letters in uppercase and type in the following formula:
=TEXTJOIN(,TRUE,CHAR(RANDARRAY(1,5,65,90,TRUE)))
- Press Enter.
The formula generates five random letters in uppercase.
Note that the formula is volatile and generates a new string of random letters each time you recalculate the worksheet. If you want to freeze the string, copy and paste it as a value.
Explanation of the formula
=TEXTJOIN(,TRUE,CHAR(RANDARRAY(1,5,65,90,TRUE)))
- =RANDARRAY(1,5,65,90,TRUE) The RANDARRAY function is the innermost in the formula, and it returns a row of five integers between 65 and 90.
Note that 65 is the ASCII code for “A,” and 90 is the ASCII code for “Z.”
- CHAR(RANDARRAY(1,5,65,90,TRUE)) The CHAR function is the second innermost function in the formula, and it converts the five integers returned by the RANDARRAY function to five uppercase letters.
- Finally, the TEXTJOIN function joins the five letters returned by the CHAR function into a string of random letters in uppercase.
Generate a String of Random Letters (a Mix of Uppercase and Lowercase Letters)
You may want to generate a string with a mix of random uppercase and lowercase letters.
We use the steps below to generate a string of ten random letters, five in uppercase and five in lowercase:
- Select the cell to which you want to add a string with a mix of random lowercase and uppercase letters and type in the following formula:
=TEXTJOIN(,TRUE,CHAR(RANDARRAY(1,5,65,90,TRUE)))&TEXTJOIN(,TRUE,CHAR(RANDARRAY(1,5,97,122,TRUE)))
- Press Enter.
The formula generates a string of ten random letters, five in uppercase and five in lowercase.
Explanation of the formula
=TEXTJOIN(,TRUE,CHAR(RANDARRAY(1,5,65,90,TRUE)))&TEXTJOIN(,TRUE,CHAR(RANDARRAY(1,5,97,122,TRUE)))
- =TEXTJOIN(,TRUE,CHAR(RANDARRAY(1,5,65,90,TRUE))) This first part of the formula generates five random uppercase letters. Note that the value 65 is the ASCII code for “A,” and 90 is the ASCII code for “Z.”
- TEXTJOIN(,TRUE,CHAR(RANDARRAY(1,5,97,122,TRUE))) This second part of the formula produces five random lowercase letters. Note that 97 is the ASCII code for “a,” and 122 is the ASCII code for “z.”
- Finally, the ampersand operator (&) joins the five random uppercase letters to the five random lowercase letters.
Note: The formula is volatile and generates a new string of random letters each time the worksheet recalculates. If you want to freeze the string, copy and paste it as a value.
Also read: How to Remove Commas in Excel (from Numbers or Text String)
Situations Where Generating Random Letters Could Be Useful
Generating random letters in Excel can be helpful in different scenarios.
Here are some examples:
- Placeholder data: When creating mock data for a presentation or demonstration, you may need to fill a column with random letters as a placeholder for data that you will enter later.
- Testing: If you need to test a formula that requires the input of letters, you can generate random letters to test the formula.
- Unique identifiers: You can use random letters as unique identifiers or codes for tracking and organizing data, for example, when creating unique IDs for a large dataset.
This tutorial showed three techniques for generating random letters in Excel.
One method explained how to generate random letters with duplicates, and the other showed how to generate random letters without duplicates.
The third method showed how to generate a string of random letters in Excel.
Each method has its advantages and disadvantages, and the best technique for generating random letters in Excel will depend on your specific needs and preferences.
We hope you found this Excel tutorial helpful.
Other Excel articles you may also like:
- How to Generate Random Names in Excel
- How to Change All Caps to Lowercase Except the First Letter in Excel?
- Extract Last Name in Excel
- How to Convert to Sentence Case in Excel?
- How to Add Text to the Beginning or End of all Cells in Excel
- How to Remove Text after a Specific Character in Excel (3 Easy Methods)
- How to Remove a Specific Character from a String in Excel