Excel Help

Associate
Joined
14 Apr 2011
Posts
1,154
Location
Stafford
Hi,

At my place of work we use temp passwords for the guest Wifi in the form of a username and password in the form of GuestXXX where xxx is any three random charaters although not repeats of the ones before. What I need is an excel spredsheet that will allow me to print multiple copies of the sheet that we use with each code on to give out to people that will contain a random code but ensure they are all different. So ineffect I need 1 document that will change the three charaters ever time it prints.

Can anyone help with this as I dont really have a clue where to start and am currently doing it manually and it takes a fair bit of time.

Thanks,

Steve.
 
Spreadsheet with two sheets -

one with a field where you can type how many copies you want (cell B1 on "Sheet1") and a button that fires a macro

one with a field that will contain the password (cell B1 on "Sheet2") and any other information you want printed

Then some macro code for your button -

Code:
Sub Rectangle1_Click()
For i = 1 To Worksheets("Sheet1").Cells(1, 2).Value
    Rnd (-1)
    Randomize (Timer)
    baseString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
    baseLength = Len(baseString)
    pass = "Guest"
    For j = 1 To 3
        pass = pass + Mid$(baseString, CInt(Int(baseLength * Rnd())) + 1, 1)
    Next j
    Worksheets("Sheet2").Cells(1, 2) = pass
    Sheets("Sheet2").PrintOut
Next i
End Sub

.. pretty basic but it should give you a start.
 
Last edited:
Back
Top Bottom