{"id":133,"date":"2008-08-18T13:58:30","date_gmt":"2008-08-18T12:58:30","guid":{"rendered":"http:\/\/simoncpage.co.uk\/blog\/?p=133"},"modified":"2009-01-06T18:14:28","modified_gmt":"2009-01-06T17:14:28","slug":"excel-vb-random-password-generator","status":"publish","type":"post","link":"https:\/\/simoncpage.co.uk\/blog\/2008\/08\/excel-vb-random-password-generator\/","title":{"rendered":"Excel VB | random password generator"},"content":{"rendered":"<p>There are\u00a0a\u00a0few of way I like to create random passwords usually from a Filemaker server based database, for more security,\u00a0but here is an Excel visual basic equivalent of what I use:<\/p>\n<h3>Random Password Generator<\/h3>\n<p>This code below generates passwords completely randomly.<\/p>\n<blockquote><p>Public Function RndPass(Length As Integer, Optional Lower As Boolean) As String<\/p>\n<p>Dim Max As Integer<br \/>\nDim Min As Integer<\/p>\n<p>Dim RndPassLoop As String<\/p>\n<p>Max = 126<br \/>\nMin = 48<\/p>\n<p>Randomize Timer<\/p>\n<p>If Length &lt; 8 Then<br \/>\nLength = 8<br \/>\nEnd If<\/p>\n<p>For i = 1 To Length<br \/>\nRndPassLoop = RndPassLoop &amp; Chr(Int((Max &#8211; Min + 1) * Rnd + Min))<br \/>\nNext i<\/p>\n<p>If Lower = False Then<br \/>\nRndPass = RndPassLoop<br \/>\nElse<br \/>\nRndPass = StrConv(RndPassLoop, vbLowerCase)<br \/>\nEnd If<\/p>\n<p>End Function<strong><\/strong><\/p>\n<p><strong>&#8216;add this code to a vb module<br \/>\n&#8216;syntax is RndPass(Length of password, True (lowercase) \/ Empty or False (both upper and lower)<br \/>\n&#8216;RndPass(20,1) = 20 characters lower case<\/strong><\/p><\/blockquote>\n<h3>Random Letter Generator<\/h3>\n<p>This code below will generator code for a random letter or number based string.<\/p>\n<blockquote><p>Public Function RndPassP(Phrase As String) As String<\/p>\n<p>Dim Max As Integer<br \/>\nDim Min As Integer<\/p>\n<p>Dim RndPassLoop As String<\/p>\n<p>If Len(Phrase) &lt; 12 Then<br \/>\nRndPassP = &#8220;Phrase too short &#8211; please choose something longer&#8221;<br \/>\nExit Function<br \/>\nEnd If<\/p>\n<p>If subStringCount(Phrase, &#8220;a&#8221;) + _<br \/>\nsubStringCount(Phrase, &#8220;c&#8221;) + _<br \/>\nsubStringCount(Phrase, &#8220;e&#8221;) + _<br \/>\nsubStringCount(Phrase, &#8220;i&#8221;) + _<br \/>\nsubStringCount(Phrase, &#8220;o&#8221;) + _<br \/>\nsubStringCount(Phrase, &#8220;s&#8221;) + _<br \/>\nsubStringCount(Phrase, &#8220;u&#8221;) + _<br \/>\nsubStringCount(Phrase, &#8220;r&#8221;) &lt; 4 Then<\/p>\n<p>RndPassP = &#8220;Phrase does not include enough key letters &#8211; please choose another&#8221;<br \/>\nExit Function<br \/>\nEnd If<\/p>\n<p>Phrase = StrConv(Phrase, vbLowerCase)<\/p>\n<p>Randomize Timer<\/p>\n<p>RndPassLoop = Replace(Phrase, &#8220;a&#8221;, &#8220;@&#8221;)<br \/>\nPhrase = Replace(RndPassLoop, &#8220;b&#8221;, &#8220;8&#8221;)<br \/>\nRndPassLoop = Replace(Phrase, &#8220;e&#8221;, &#8220;3&#8221;)<br \/>\nPhrase = Replace(RndPassLoop, &#8220;i&#8221;, &#8220;!&#8221;)<br \/>\nRndPassLoop = Replace(Phrase, &#8220;o&#8221;, &#8220;0&#8221;)<br \/>\nPhrase = Replace(RndPassLoop, &#8220;s&#8221;, &#8220;$&#8221;)<br \/>\nRndPassLoop = Replace(Phrase, &#8221; &#8220;, &#8220;&#8221;)<br \/>\nPhrase = Replace(RndPassLoop, &#8220;u&#8221;, &#8221; * &#8220;)<br \/>\nRndPassLoop = Replace(Phrase, &#8220;r&#8221;, &#8220;\u00a3&#8221;)<br \/>\nPhrase = Replace(RndPassLoop, &#8220;M&#8221;, &#8220;M&#8221;)<br \/>\nRndPassLoop = Replace(Phrase, &#8220;N&#8221;, &#8220;N&#8221;)<br \/>\nPhrase = Replace(RndPassLoop, &#8220;T&#8221;, &#8220;T&#8221;)<br \/>\nRndPassLoop = Replace(Phrase, &#8220;X&#8221;, &#8220;X&#8221;)<br \/>\nPhrase = Replace(RndPassLoop, &#8220;G&#8221;, &#8220;G&#8221;)<\/p>\n<p>Phrase = RndPassLoop &amp; &#8220;:)&#8221;&#8221;&#8221;<\/p>\n<p>RndPassP = Phrase<\/p>\n<p>End Function<\/p>\n<p>Function subStringCount(longString As String, subString As String) As Double<br \/>\nsubStringCount = Len(longString) _<br \/>\n&#8211; Len(Application.Substitute(longString, subString, vbNullChar))<br \/>\nEnd Function<\/p>\n<p><strong>&#8216;add this code to a vb module<br \/>\n&#8216;syntax is \u2018RndPassP(string):<br \/>\n&#8216;RndPassP (&#8220;I work in Property Finance&#8221;)<\/strong><\/p><\/blockquote>\n<p style=\"TEXT-ALIGN: left\">Let me know what you think about these and what sort of password system you use?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are\u00a0a\u00a0few of way I like to create random passwords usually from a Filemaker server based database, for more security,\u00a0but here is an Excel visual basic equivalent of what I use: Random Password Generator This code below generates passwords completely randomly. Public Function RndPass(Length As Integer, Optional Lower As Boolean) As String Dim Max As [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[26],"tags":[123,79,78,117,55,27,119,121],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/posts\/133"}],"collection":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":0,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"wp:attachment":[{"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simoncpage.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}