"VBA Study" generates random passwords

Source: Internet
Author: User

Iamlaosong

A very simple function, there are many online generators, there are also gadgets can be downloaded, here with VBA to do one, the results are saved to the current worksheet, simple, fast. The build function can also be used in other programs. The process of implementing a function is to use a variable to hold all the characters used, and then to take different substrings according to the level, and then to generate random numbers, and remove the characters from the substring to match the random password. The procedure is as follows:

' Generate password and save to current sheet sub GetPassword ()    len1 = Cells (2, 3)    LEV1 = Cells (2, 4)    NUM1 = Cells (2, 5)    MaxRow = actives Heet. UsedRange.Rows.Count    If maxrow >= 2 then        Range ("a2:a" & MaxRow). ClearContents    End If for        row1 = 2 to NUM1 + 1        Cells (row1, 1) = GENPASSWD (Len1, LEV1)    Next row1    End Su B ' generate random cipher function, Level 1 = number, Level 2 = number + lowercase letter, Level 3 = number + case letter, Level 4 = number + case Letter + symbol function genpasswd (length, levels)    Dim allstr, substr, passwd as String        allstr = "[Email protected]#$%^&* ()" Select Case level Case    1        strlen =    Case 2        strlen =    3        strlen = + Case    Else        strlen =    substr End Select = left    (al Lstr, strlen)    ' Debug.Print substr    passwd = "" For    i = 1 to length        passwd = passwd & Mid (substr, in T (Rnd * strlen + 1), 1)    Next    genpasswd = Passwdend Function
This program: Click to open the link

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"VBA Study" generates random passwords

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.