Random password gen - Excel VBA

  • Thread starter Thread starter rzal7
  • Start date Start date
R

rzal7

I have a grid of 100 random four letter words (no not BAD four lette
words!) and they range from C4 to L13. I am trying to write in VBA so
can randomly select two words from the grid to create one 8 letter wor
for random password generation. I know that this has been done, I don'
want to recreate the wheel, but right now this is eluding me. any hel
would be greatly appreciated!

RZAL7

I've attached the workbook I have so far

Attachment filename: passgenrzv01.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=59097
 
Hi Marcotte A,
I am only able to generate a dot as a password(!) using this code. Am I
doing something wrong?.
Martyn

Marcotte A said:
To attach a button to the macro, go to the view menu, select toolbars,
then select Control Toolbox. Select the icon that looks like a button (if
you hover over it it will say "Button"). Draw the button where ever you
want it on the sheet. If the macro is already in VBA, a dialog box will
open asking you which macro you want to attach the button to. Select the
appropriate one and you should be good to go.
If the macro is not in VBA when you create the Button, then once you have
added the macro, right click on the button and select "Assign Macro..."
Below is the full corrected form of the macro i posted earlier. If you
don't want to generate multiple passwords with one click of the button,
replace everything after the "Next k" line with
 
Thanks Marcotte A,
Now it functions all right. But I wonder, which code section refers to the
C4:L13 area cells?
TIA

Marcotte A said:
Do you have source words in the range C4:L13? The code is designed to
pick 2 random cells from a 10x10 range filled with 4 letter strings and
combine them. I'm guessing that those cells are blank so the Password
variable never changes from "", so when the MsgBox displays you just get
what is in the double quotes (including the final dot).
 
Password = Password & Worksheets("sheet1").Cells(3 + i, 2 + j)

Note the Worksheets("sheet1").Cells(3 + i, 2 + j) bit. The cells(x, y) section
of that statement is a way of referencing a cell. If you ignore the i and j bit
for the moment, you get Cells(3, 2) which is the same as Cells(Row 3, Column 2)
which is the cell B2.

Now, here is where the i and j come into play. Based on the code, i and j will
always be equal to somewhere between 1 and 10 inclusive, so the Cells(Row,
Column) bit will always give you Cells(Row 3 + {1 to 10}, Column 2 + {1 to 10}),
so the very minimum you will get is

Cells(Row 3 + 1, Column 2 + 1), which equals Cells(4, 3), which equals C4

and the max

Cells(Row 3 + 10, Column 2 + 10), which equals Cells(13, 12), which equals L14

so your range of C4:L14 is encompassed within those parameters

The Worksheets("sheet1"). before the Cells(... bit, simply says that the range
being referred to is on Sheet1.
 
Now this is what I call "detailed info". Thanks a lot Ken.
Your answer to my question is "complete".
MARTYN
 
My pleasure, but it was just an explanation of Marcotte's code, so credit where
it's due ( ie Marcotte :-> ), especially for sticking at it till you got sorted
:-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top