How to create a Password using VBA Excel

 How to create a Password using VBA Excel 

1st create a UserForm in Excel. 

Password Generator

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 Explicit


Private Sub cmdRefresh_Click()
    ' Handle the Refresh button click event
    GenerateCAPTA
End Sub

Private Sub GenerateCAPTA()
    ' Generate a new CAPTA and display it in TextBox1
    TextBox1.Value = GenPw(20)
End Sub


Private Function GenPw(length As Integer) As String
    ' Function to generate a random CAPTA
    Dim characters As String
    Dim i As Integer
    Dim charIndex As Integer
    Dim result As String

    ' Define the characters to use in the CAPTA
    characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+"

    ' Seed the random number generator
    Randomize

    ' Build the CAPTA with random characters
    For i = 1 To length
        charIndex = Int((Len(characters) * Rnd) + 1)
        result = result & Mid(characters, charIndex, 1)
    Next i

    GenPw = result
End Function


Private Sub UserForm_Initialize()
    ' Initialize the UserForm
    GenerateCAPTA
End Sub





Just it is copy and paste in Userform1 Process: 

1. Click to the Developer Option 

Developer Option



2. Select the UserForm1 

Select the UserForm1


3. Double click on Userform1

Double click on Userform1

4. Paste here the copy text

Paste here the copy text




5. You Can Click to "New Pass" Button and Generate Password 

Generate Password









 
Previous Post Next Post