How to create a Password using VBA Excel
1st create a UserForm in Excel.
It have one TextBox & one Button, there name is Textbox1 & click New Pass to Generate the Random Password of VBA Excel UserForm. It is Password Generated UserForm1.
Code:
Option ExplicitPrivate Sub cmdRefresh_Click()' Handle the Refresh button click eventGenerateCAPTAEnd SubPrivate Sub GenerateCAPTA()' Generate a new CAPTA and display it in TextBox1TextBox1.Value = GenPw(20)End SubPrivate Function GenPw(length As Integer) As String' Function to generate a random CAPTADim characters As StringDim i As IntegerDim charIndex As IntegerDim result As String' Define the characters to use in the CAPTAcharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+"' Seed the random number generatorRandomize' Build the CAPTA with random charactersFor i = 1 To lengthcharIndex = Int((Len(characters) * Rnd) + 1)result = result & Mid(characters, charIndex, 1)Next iGenPw = resultEnd FunctionPrivate Sub UserForm_Initialize()' Initialize the UserFormGenerateCAPTAEnd Sub
Just it is copy and paste in Userform1 Process:
1. Click to the Developer Option
2. Select the UserForm1
3. Double click on Userform1
5. You Can Click to "New Pass" Button and Generate Password
Tags:
VBA Password Generator