Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 72
Default Randomiser - to create scrambled passwords

Hi All,

Once again I am being lazy. Does someone have either a function or an
elegant approach to take a text string and randomise it (to create a password
for WinZip in this instance)?

Thanks in Advance and Best Regards,

Matt
  #2   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Randomiser - to create scrambled passwords

a function or an elegant approach to take a text string
and randomise it (to create a password for WinZip in this instance)?


One good way that I know of is to install & use
the UDF Scramble below by Jim Cone ..
(UDF = user defined function)

To install the UDF:
Press Alt+F11 to go to VBE
Click Insert Module
Copy n paste the UDF into the code window (whitespace on right)
Press Alt+Q to get back to Excel

In Excel,
Assuming your data to be scrambled is in A1 down,
Put in B1: =scramble(A1,x)
Copy B1 down to return the random scrambles

Press F9 to re-scramble
The "x" can be any entry, number or text (any length), as the second
argument


' Apr 14, 2002 - Created - James Cone - San Francisco USA
' Scrambles the order of the data in a single-cell.
' Nov 02, 2003 - Last update
'--------------------------------------
Function SCRAMBLE(Optional ByRef UserText As Variant, _
Optional ByRef Everytime As Variant) As String
On Error GoTo Scorched
Dim i As Long
Dim Num As Long
Dim NewPosition As Long
Dim Temp As String
If IsMissing(UserText) Then
SCRAMBLE = "No data"
Exit Function
' No quotes automatically generates an error from the worksheet.
ElseIf IsError(UserText) Then
SCRAMBLE = "Error - try adding quote marks around your entry."
Exit Function
End If
Application.Volatile (Not IsMissing(Everytime))
If TypeName(UserText) = "Range" Then UserText = UserText(1).Value
Num = Len(UserText)
If Num 0 Then
For i = 1 To Num
Temp = Mid$(UserText, i, 1)
NewPosition = Int(Num * Rnd + 1)
Mid$(UserText, i, 1) = Mid$(UserText, NewPosition, 1)
Mid$(UserText, NewPosition, 1) = Temp
Next ' i
SCRAMBLE = UserText
Else
SCRAMBLE = "No data" 'Can result from entering ""
End If
Exit Function
Scorched:
SCRAMBLE = "Error " & Err.Number
End Function
'--------------------
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:22,500 Files:370 Subscribers:66
xdemechanik
---
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 72
Default Randomiser - to create scrambled passwords

That looks just the ticket.

However is there something else I need to do to get EXcel to "recognise" the
function? (It isn't working).

I tried adding "Option Explicit" at the top of the module to attempt to
emulate another function I have in another module that works.

"Max" wrote:

a function or an elegant approach to take a text string
and randomise it (to create a password for WinZip in this instance)?


One good way that I know of is to install & use
the UDF Scramble below by Jim Cone ..
(UDF = user defined function)

To install the UDF:
Press Alt+F11 to go to VBE
Click Insert Module
Copy n paste the UDF into the code window (whitespace on right)
Press Alt+Q to get back to Excel

In Excel,
Assuming your data to be scrambled is in A1 down,
Put in B1: =scramble(A1,x)
Copy B1 down to return the random scrambles

Press F9 to re-scramble
The "x" can be any entry, number or text (any length), as the second
argument


' Apr 14, 2002 - Created - James Cone - San Francisco USA
' Scrambles the order of the data in a single-cell.
' Nov 02, 2003 - Last update
'--------------------------------------
Function SCRAMBLE(Optional ByRef UserText As Variant, _
Optional ByRef Everytime As Variant) As String
On Error GoTo Scorched
Dim i As Long
Dim Num As Long
Dim NewPosition As Long
Dim Temp As String
If IsMissing(UserText) Then
SCRAMBLE = "No data"
Exit Function
' No quotes automatically generates an error from the worksheet.
ElseIf IsError(UserText) Then
SCRAMBLE = "Error - try adding quote marks around your entry."
Exit Function
End If
Application.Volatile (Not IsMissing(Everytime))
If TypeName(UserText) = "Range" Then UserText = UserText(1).Value
Num = Len(UserText)
If Num 0 Then
For i = 1 To Num
Temp = Mid$(UserText, i, 1)
NewPosition = Int(Num * Rnd + 1)
Mid$(UserText, i, 1) = Mid$(UserText, NewPosition, 1)
Mid$(UserText, NewPosition, 1) = Temp
Next ' i
SCRAMBLE = UserText
Else
SCRAMBLE = "No data" 'Can result from entering ""
End If
Exit Function
Scorched:
SCRAMBLE = "Error " & Err.Number
End Function
'--------------------
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:22,500 Files:370 Subscribers:66
xdemechanik
---

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 72
Default Randomiser - to create scrambled passwords

OK - I've read the Help - it's out of scope cos it's in Percy.

"Max" wrote:

a function or an elegant approach to take a text string
and randomise it (to create a password for WinZip in this instance)?


One good way that I know of is to install & use
the UDF Scramble below by Jim Cone ..
(UDF = user defined function)

To install the UDF:
Press Alt+F11 to go to VBE
Click Insert Module
Copy n paste the UDF into the code window (whitespace on right)
Press Alt+Q to get back to Excel

In Excel,
Assuming your data to be scrambled is in A1 down,
Put in B1: =scramble(A1,x)
Copy B1 down to return the random scrambles

Press F9 to re-scramble
The "x" can be any entry, number or text (any length), as the second
argument


' Apr 14, 2002 - Created - James Cone - San Francisco USA
' Scrambles the order of the data in a single-cell.
' Nov 02, 2003 - Last update
'--------------------------------------
Function SCRAMBLE(Optional ByRef UserText As Variant, _
Optional ByRef Everytime As Variant) As String
On Error GoTo Scorched
Dim i As Long
Dim Num As Long
Dim NewPosition As Long
Dim Temp As String
If IsMissing(UserText) Then
SCRAMBLE = "No data"
Exit Function
' No quotes automatically generates an error from the worksheet.
ElseIf IsError(UserText) Then
SCRAMBLE = "Error - try adding quote marks around your entry."
Exit Function
End If
Application.Volatile (Not IsMissing(Everytime))
If TypeName(UserText) = "Range" Then UserText = UserText(1).Value
Num = Len(UserText)
If Num 0 Then
For i = 1 To Num
Temp = Mid$(UserText, i, 1)
NewPosition = Int(Num * Rnd + 1)
Mid$(UserText, i, 1) = Mid$(UserText, NewPosition, 1)
Mid$(UserText, NewPosition, 1) = Temp
Next ' i
SCRAMBLE = UserText
Else
SCRAMBLE = "No data" 'Can result from entering ""
End If
Exit Function
Scorched:
SCRAMBLE = "Error " & Err.Number
End Function
'--------------------
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:22,500 Files:370 Subscribers:66
xdemechanik
---

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Randomiser - to create scrambled passwords

What is "Percy"?


Gord Dibben MS Excel MVP

On Mon, 2 Feb 2009 16:44:00 -0800, veryeavy
wrote:

OK - I've read the Help - it's out of scope cos it's in Percy.

"Max" wrote:

a function or an elegant approach to take a text string
and randomise it (to create a password for WinZip in this instance)?


One good way that I know of is to install & use
the UDF Scramble below by Jim Cone ..
(UDF = user defined function)

To install the UDF:
Press Alt+F11 to go to VBE
Click Insert Module
Copy n paste the UDF into the code window (whitespace on right)
Press Alt+Q to get back to Excel

In Excel,
Assuming your data to be scrambled is in A1 down,
Put in B1: =scramble(A1,x)
Copy B1 down to return the random scrambles

Press F9 to re-scramble
The "x" can be any entry, number or text (any length), as the second
argument


' Apr 14, 2002 - Created - James Cone - San Francisco USA
' Scrambles the order of the data in a single-cell.
' Nov 02, 2003 - Last update
'--------------------------------------
Function SCRAMBLE(Optional ByRef UserText As Variant, _
Optional ByRef Everytime As Variant) As String
On Error GoTo Scorched
Dim i As Long
Dim Num As Long
Dim NewPosition As Long
Dim Temp As String
If IsMissing(UserText) Then
SCRAMBLE = "No data"
Exit Function
' No quotes automatically generates an error from the worksheet.
ElseIf IsError(UserText) Then
SCRAMBLE = "Error - try adding quote marks around your entry."
Exit Function
End If
Application.Volatile (Not IsMissing(Everytime))
If TypeName(UserText) = "Range" Then UserText = UserText(1).Value
Num = Len(UserText)
If Num 0 Then
For i = 1 To Num
Temp = Mid$(UserText, i, 1)
NewPosition = Int(Num * Rnd + 1)
Mid$(UserText, i, 1) = Mid$(UserText, NewPosition, 1)
Mid$(UserText, NewPosition, 1) = Temp
Next ' i
SCRAMBLE = UserText
Else
SCRAMBLE = "No data" 'Can result from entering ""
End If
Exit Function
Scorched:
SCRAMBLE = "Error " & Err.Number
End Function
'--------------------
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:22,500 Files:370 Subscribers:66
xdemechanik
---




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 72
Default Randomiser - to create scrambled passwords

Percy is (London?) drug slang for personal, as in "for personal use".

In this case I am referring to the Personal Macro workbook.

HTH.

"Gord Dibben" wrote:

What is "Percy"?


Gord Dibben MS Excel MVP

On Mon, 2 Feb 2009 16:44:00 -0800, veryeavy
wrote:

OK - I've read the Help - it's out of scope cos it's in Percy.

"Max" wrote:

a function or an elegant approach to take a text string
and randomise it (to create a password for WinZip in this instance)?

One good way that I know of is to install & use
the UDF Scramble below by Jim Cone ..
(UDF = user defined function)

To install the UDF:
Press Alt+F11 to go to VBE
Click Insert Module
Copy n paste the UDF into the code window (whitespace on right)
Press Alt+Q to get back to Excel

In Excel,
Assuming your data to be scrambled is in A1 down,
Put in B1: =scramble(A1,x)
Copy B1 down to return the random scrambles

Press F9 to re-scramble
The "x" can be any entry, number or text (any length), as the second
argument


' Apr 14, 2002 - Created - James Cone - San Francisco USA
' Scrambles the order of the data in a single-cell.
' Nov 02, 2003 - Last update
'--------------------------------------
Function SCRAMBLE(Optional ByRef UserText As Variant, _
Optional ByRef Everytime As Variant) As String
On Error GoTo Scorched
Dim i As Long
Dim Num As Long
Dim NewPosition As Long
Dim Temp As String
If IsMissing(UserText) Then
SCRAMBLE = "No data"
Exit Function
' No quotes automatically generates an error from the worksheet.
ElseIf IsError(UserText) Then
SCRAMBLE = "Error - try adding quote marks around your entry."
Exit Function
End If
Application.Volatile (Not IsMissing(Everytime))
If TypeName(UserText) = "Range" Then UserText = UserText(1).Value
Num = Len(UserText)
If Num 0 Then
For i = 1 To Num
Temp = Mid$(UserText, i, 1)
NewPosition = Int(Num * Rnd + 1)
Mid$(UserText, i, 1) = Mid$(UserText, NewPosition, 1)
Mid$(UserText, NewPosition, 1) = Temp
Next ' i
SCRAMBLE = UserText
Else
SCRAMBLE = "No data" 'Can result from entering ""
End If
Exit Function
Scorched:
SCRAMBLE = "Error " & Err.Number
End Function
'--------------------
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:22,500 Files:370 Subscribers:66
xdemechanik
---



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 143
Default Randomiser - to create scrambled passwords

Once again I am being lazy. Does someone have either a function or an
elegant approach to take a text string and randomise it (to create a
password for WinZip in this instance)?


One way is

(a) put the letters A-Z in A1:A26 (or your favorite characters)

(b) put =RAND() in B1:B26

(c) sort A:B by column B

(d) take the A1:A9 values as a 9-letter pasword (or more or fewer)

Not elegant and not function, but I find it fast and easy.
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 72
Default Randomiser - to create scrambled passwords

You must be a mind reader - that is exactly what I was doing with a touch of
"TRANSPOSE" thrown in.

Suggest you try what Max suggested as it is very simple to operate (and if
you haven't already experimented with user-defined functions most
educational).

Thanks!

"MyVeryOwnSelf" wrote:

Once again I am being lazy. Does someone have either a function or an
elegant approach to take a text string and randomise it (to create a
password for WinZip in this instance)?


One way is

(a) put the letters A-Z in A1:A26 (or your favorite characters)

(b) put =RAND() in B1:B26

(c) sort A:B by column B

(d) take the A1:A9 values as a 9-letter pasword (or more or fewer)

Not elegant and not function, but I find it fast and easy.

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Randomiser - to create scrambled passwords

Thought it might be some type of slang.

If the UDF is in Personal.xls you must preface with that filename.

=Personal.xls!SCRAMBLE(text)


Gord

On Mon, 2 Feb 2009 17:19:01 -0800, veryeavy
wrote:

Percy is (London?) drug slang for personal, as in "for personal use".

In this case I am referring to the Personal Macro workbook.

HTH.

"Gord Dibben" wrote:

What is "Percy"?


Gord Dibben MS Excel MVP

On Mon, 2 Feb 2009 16:44:00 -0800, veryeavy
wrote:

OK - I've read the Help - it's out of scope cos it's in Percy.

"Max" wrote:

a function or an elegant approach to take a text string
and randomise it (to create a password for WinZip in this instance)?

One good way that I know of is to install & use
the UDF Scramble below by Jim Cone ..
(UDF = user defined function)

To install the UDF:
Press Alt+F11 to go to VBE
Click Insert Module
Copy n paste the UDF into the code window (whitespace on right)
Press Alt+Q to get back to Excel

In Excel,
Assuming your data to be scrambled is in A1 down,
Put in B1: =scramble(A1,x)
Copy B1 down to return the random scrambles

Press F9 to re-scramble
The "x" can be any entry, number or text (any length), as the second
argument


' Apr 14, 2002 - Created - James Cone - San Francisco USA
' Scrambles the order of the data in a single-cell.
' Nov 02, 2003 - Last update
'--------------------------------------
Function SCRAMBLE(Optional ByRef UserText As Variant, _
Optional ByRef Everytime As Variant) As String
On Error GoTo Scorched
Dim i As Long
Dim Num As Long
Dim NewPosition As Long
Dim Temp As String
If IsMissing(UserText) Then
SCRAMBLE = "No data"
Exit Function
' No quotes automatically generates an error from the worksheet.
ElseIf IsError(UserText) Then
SCRAMBLE = "Error - try adding quote marks around your entry."
Exit Function
End If
Application.Volatile (Not IsMissing(Everytime))
If TypeName(UserText) = "Range" Then UserText = UserText(1).Value
Num = Len(UserText)
If Num 0 Then
For i = 1 To Num
Temp = Mid$(UserText, i, 1)
NewPosition = Int(Num * Rnd + 1)
Mid$(UserText, i, 1) = Mid$(UserText, NewPosition, 1)
Mid$(UserText, NewPosition, 1) = Temp
Next ' i
SCRAMBLE = UserText
Else
SCRAMBLE = "No data" 'Can result from entering ""
End If
Exit Function
Scorched:
SCRAMBLE = "Error " & Err.Number
End Function
'--------------------
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:22,500 Files:370 Subscribers:66
xdemechanik
---




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formulas scrambled when sorting Mic Excel Worksheet Functions 0 June 19th 08 09:06 PM
Randomiser Steve[_9_] Excel Discussion (Misc queries) 3 May 6th 08 11:03 PM
DATES ARE SCRAMBLED! FARAZ QURESHI Excel Discussion (Misc queries) 9 February 12th 08 09:11 PM
Can I create Multiple passwords to edit multiple ranges? Conker10382 Excel Discussion (Misc queries) 8 December 31st 06 07:58 PM
Can I create multi-level passwords for the same workbook waterskyle Excel Worksheet Functions 0 March 18th 05 07:51 PM


All times are GMT +1. The time now is 07:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"