Click = Random Charaters Into A Cell

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Thanks,

is there a way to make this into such away that when i click the cell the
random password is inputted stright away? as i dont want to have to copy and
past the formula each time

regards,

chris
 
Chris,

Try this. Right click your sheet tab, view code and paste this in. It works
on Column C only and only if the cell is blank. The formula as supplied by
Teethless Mama has wrapped so you will have to unwrap it. Double click the
cell to get a number.


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Value = "" And ActiveCell.Column = 3 Then
Target.Formula =
"=CHAR(RANDBETWEEN(CODE(""A""),CODE(""Z"")))&CHAR(RANDBETWEEN(CODE(""A""),CODE(""Z"")))&CHAR(RANDBETWEEN(CODE(""a""),CODE(""z"")))&CHAR(RANDBETWEEN(CODE(""a""),CODE(""z"")))&CHAR(RANDBETWEEN(CODE(""a""),CODE(""z"")))&CHAR(RANDBETWEEN(CODE(""a""),CODE(""z"")))&CHAR(RANDBETWEEN(CODE(""a""),CODE(""z"")))&RANDBETWEEN(1,9)"
Target.Copy
ActiveCell.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Target.Offset(1, 0).Select
End If
End Sub

Mike
 
Back
Top