SCRAMBLE
SCRAMBLE(sCellContents)
Returns the cell contents with all the characters in a random order.
| sCellContents | The number or text you want to scramble. |
REMARKS
Public Function SCRAMBLE( _
Public Function SCRAMBLE( _
ByVal sCellContents As String) _
As String
Dim itextlength As Integer
Dim ichar As Integer
Dim irandomposition As Integer
Dim scharacter As String * 1
itextlength = Len(sCellContents)
For ichar = 1 To itextlength
scharacter = VBA.Mid(sCellContents, ichar, 1)
irandomposition = VBA.Int((itextlength - 1 + 1) * VBA.Rnd + 1)
Mid(sCellContents, ichar, 1) = VBA.Mid(sCellContents, irandomposition, 1)
Mid(sCellContents, irandomposition, 1) = scharacter
Next ichar
SCRAMBLE = sCellContents
End Function
You can use the RANDOMNUMBER function to return a random number between two bounds.
This user defined function is called "RANDOM" in the ASAP add-in.
![]() |
For instructions on how to add this function to a workbook refer to the page under Inserting Functions
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext
