Excel formula tutorial

How to Make a Password Generator in Excel

Create random strings with modern Excel formulas, control the length and character groups, and convert changing formulas into fixed values.

16-character Excel password formula

Paste this formula into an empty cell in Excel for Microsoft 365, Excel 2024, or Excel 2021:

Random 16-character value
=LET(pool,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*",TEXTJOIN("",TRUE,MID(pool,RANDARRAY(16,1,1,LEN(pool),TRUE),1)))

Excel will generate a new value from the combined character pool. Copy the result and paste it as a value before using it as fixed test data.

Security boundary: Microsoft documents what these functions return, but does not document RANDARRAY as a cryptographically secure random-number generator. Use these formulas for demonstrations, classroom exercises, QA, or synthetic test data—not for production account credentials, encryption keys, API secrets, or recovery codes.

How the Excel password formula works

The formula combines four standard Excel operations:

  1. LET assigns the character set to the name pool, so it is defined once and reused.
  2. RANDARRAY(16,1,1,LEN(pool),TRUE) returns 16 random whole-number positions from the pool.
  3. MID extracts the character at each selected position.
  4. TEXTJOIN combines the 16 selected characters without a separator.

Repeated characters are allowed. That is normal for independent selection and avoids silently changing the requested character distribution.

Make the password length configurable

Enter the desired length in cell A1, then use A1 as the row count passed to RANDARRAY:

Length controlled by cell A1
=LET(pool,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*",TEXTJOIN("",TRUE,MID(pool,RANDARRAY(A1,1,1,LEN(pool),TRUE),1)))

Use a positive whole number in A1. A service can still reject the output when its maximum length or allowed-symbol rules differ, so check the destination requirements.

Require uppercase, lowercase, a number, and a symbol

The simple formula selects from a mixed pool but does not guarantee that every output contains every character category. This longer formula selects one required character from each category, adds 12 more characters, and shuffles all 16 positions:

16 characters with all four groups
=LET(upper,"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lower,"abcdefghijklmnopqrstuvwxyz",digits,"0123456789",symbols,"!@#$%^&*",pool,upper&lower&digits&symbols,required,MID(upper,RANDBETWEEN(1,LEN(upper)),1)&MID(lower,RANDBETWEEN(1,LEN(lower)),1)&MID(digits,RANDBETWEEN(1,LEN(digits)),1)&MID(symbols,RANDBETWEEN(1,LEN(symbols)),1),extra,TEXTJOIN("",TRUE,MID(pool,RANDARRAY(12,1,1,LEN(pool),TRUE),1)),combined,required&extra,TEXTJOIN("",TRUE,SORTBY(MID(combined,SEQUENCE(LEN(combined)),1),RANDARRAY(LEN(combined)))))

The formula guarantees composition, not cryptographic security. If the target rejects a symbol, edit the symbols value to match its published allowed-character list.

Why the generated password keeps changing

Microsoft identifies RANDARRAY as a volatile function: Excel can produce a new array when the workbook recalculates. Editing another cell, opening the workbook, or initiating recalculation can therefore replace the displayed result.

  1. Select the generated cell.
  2. Copy it.
  3. Use Paste Special → Values in a separate cell.
  4. Verify the pasted cell contains text rather than the formula.
  5. Delete the volatile formula when it is no longer needed.
Do not rely on the formula cell as storage. A later recalculation can leave the workbook showing a different value from the one assigned to a test account.

Generate a column of sample passwords

Place a formula in the first row and fill it down for as many synthetic records as needed. Then paste the finished column as values. Random generation does not mathematically guarantee uniqueness, so use Excel's duplicate highlighting or a uniqueness check before importing a large test set.

For a ready-made local workflow with unique batches and CSV or JSON Lines export, use the username and password generator or email and password test-data generator.

Excel version and locale requirements

Microsoft lists LET and RANDARRAY for Excel 2021, Excel 2024, Microsoft 365, and their supported Mac editions. TEXTJOIN is also available in Excel 2019, but the formulas on this page require the newer dynamic-array functions. Excel for the web can support these functions when the workbook and account version expose them.

Some regional settings use semicolons instead of commas as formula separators, and localized Excel installations may display translated function names. If Excel reports a formula syntax error, use the separator and function names shown by that installation.

Should Excel store real passwords?

A spreadsheet can be copied, synced, emailed, backed up, exposed through sharing permissions, or included in version history. It also lacks the purpose-built autofill, per-entry access controls, breach alerts, and credential workflows of a password manager. Do not maintain a plaintext workbook of real passwords.

For an actual account, use a password manager's generator or create a cryptographically random value with the site's browser password generator. This site uses the Web Crypto API locally and does not place generated values in URLs or browser storage.

Excel password generator questions

Can Excel generate random passwords?

Yes. RANDARRAY can select positions from a character pool, MID can retrieve those characters, and TEXTJOIN can combine them. The result is useful for samples and test data, but Microsoft does not describe RANDARRAY as a cryptographic generator.

How do I stop an Excel password from changing?

Copy the generated cell and paste it as a value. Confirm the destination cell no longer contains the formula before deleting the source.

Can the formula exclude confusing characters?

Yes. Remove characters such as 0, O, 1, l, and I from the pool string. The formula will then select only from the remaining characters.

Does the formula work in Excel for Mac?

Microsoft lists LET and RANDARRAY for supported Excel 2021, Excel 2024, and Microsoft 365 releases on Mac. Locale and update differences can affect separators and function availability.

Sources and reviewed scope

This independent guide was reviewed against current Microsoft function documentation on October 1, 2026. Generate My Password is not affiliated with or endorsed by Microsoft.