# Excel random password generator

Sometimes you may have to generate automatically different random passwords. This could be a very easy task if you just had an Excel function like “RandomPassword”, so you could write:

```=RandomPassword(8)
```

And get something like:

```e8NwB9Bi
```

Well, this is exactly the idea of the Add-In I’ve made…

If this isn’t what you’re looking for, as an alternative, you can visit the online random password generator.

The function syntax is as follows:

```=RandomPassword(length, [uppercase = TRUE], [numbers = TRUE],
[lowercase = TRUE])
```

Just as simple as that… Here are the download links:

If you don’t know how you should install an Excel Add-in, keep looking into the site since I’ll write a post about that soon… By now, I can give you this guidelines:

1- Copy the corresponding version of the add-in (XLA or XLAM) to C:\Program Files\Microsoft Office\OfficeXX\Library (where XX is the Office version, being 12 for Office 2007)
2- Follow the instructions given here for Office 2003 or below, or take a look at the first part of this steps for Office 2007.

Just in case you want to see the function code without looking into the add-in:

```Function RandomPassword(Length As Integer, Optional Upper As Boolean = True, Optional Number As Boolean = True, Optional Lower As Boolean = True)
If Not Upper And Not Lower And Not Number Then
Exit Function
End If

Dim Ret As String
Dim Num As Integer
Dim Repeat As Boolean

Randomize

Chars = 26 * 2 + 10 '26 (a-z) + 26 (A-Z) + 10 (0-9)
'a-z = 97-122
'A-Z = 65-90
'0-9 = 48-57

For i = 1 To Length
Repeat = False

Num = Int(Chars * Rnd) 'Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

If Num &amp;lt; 26 Then        'a-z
If Lower Then
Ret = Ret & Chr(Num + 97)
Else
Repeat = True
End If
ElseIf Num < 52 Then    'A-Z
If Upper Then
Ret = Ret & Chr(Num - 26 + 65)
Else
Repeat = True
End If
ElseIf Num < 62 Then    '0-9
If Number Then
Ret = Ret & Chr(Num - 52 + 48)
Else
Repeat = True
End If
End If

If Repeat Then
i = i - 1
End If
Next i

End Function
```

### Support appreciated!

All the content offered in this website is, except noted otherwise, of free nature. This means you can share it wherever you want if you do it freely and stating its source.

If it was useful for you and you’d like to contribute, you can make a donation or, at least, visit one of our advertisers of your choice; they are all around the site.

#### 17 Responses to “Excel random password generator”

• jordan

Thanks a lot for ur work, i think it will help me,

• You’re welcome!
Greetings!

• James C

This is such a great tool. Is there a way you can add special Characters to the add in? e.g. * @ ^

• I’ll do it in a while…
Subscribe to the feed so you can get notified…
Greetings!

• Keith M

Fantastic function. I have been racking my brains trying to get this to work.

• I’m glad it helped!!
Thanks for your comment!
Greetings!

• Mateusz

Great – it works. I would like to ask if this is possible to edit content of xlam file – I would like to get some additional knowledge.
I would like to ask if it possible to call such ADD-on from macro (how – using Excel_function or how is called this function)?
I would like to write macro which will fill all cell in selected range (for each cell in range) typing there generated password.

• Ron

Anyway to add symbols like ! @ # \$ % ^ & *
I’ll donate more if possible. Thank you.

• Maarten Tijssens

Wonderful tool, just what I am looking for … for Office 2010! Any suggestions? It goes fine until I have to add the ‘button’ to the ribbon.

• thanks a lot for your work. I’ve been using this tool for a while. Since I am going to move Office 2010, I wonder if it works with Excel 2010. Your download links are only for 2003 and 2007.

Thanks

• What would be a little nicer for the user is checkboxes for the options, so it’s not necessary to type “true” or “false” into all of those cells.

Actually it might be even more slick to put it all into a UserForm.

• nhyiraba

am very great for the code , it really work for me and am happy

• Thomas

Awesome, I was looking for something like this and found it…Thank you.

• Tijuana

It duplicate password…try that on a column and than order alpha..(excel 2007)

• Farid

you, my man, are a LIFE SAVER !

brilliant mind ! fabulous function !

• Gino

Passwords are not unique!

• They are random. Nothing guarantees the’re unique. If you generate lots of passwords chances are they’ll repeat.
Best regards.
NeoEGM.