Hitta nått kul:
13 Pixlar   /   Tips   /   Kodtips   /   Slumpa fram ett lösenord i Excel

Slumpa fram ett lösenord i Excel

19 december, 2014

Följande makro kan användas för att slumpa fram ett lösenord i Excel


Sub PassGen()
'
' Password Makro For Excel
'

Dim Cell As Range
For Each Cell In Application.Selection

    Randomize
    Password = ""
    
    For I = 1 To 7
        XrT = Int(Rnd * 8) + 1
        Select Case XrT
            Case 1
            PsSt = 65: PsSl = 25
            Case 2
            PsSt = 97: PsSl = 25
            Case 3
            PsSt = 65: PsSl = 25
            Case 4
            PsSt = 49: PsSl = 8
            Case 5
            PsSt = 65: PsSl = 25
            Case 6
            PsSt = 97: PsSl = 25
            Case 7
            PsSt = 65: PsSl = 25
            Case 8
            PsSt = 97: PsSl = 25
        End Select
        
        Password = Password & Chr(Int(Rnd * PsSl) + PsSt)
    Next I
    
    Cell.Value = LCase(Password)
    
Next Cell

Dim Markering As String
Markering = Selection.Address
Range(Markering).Select

End Sub