View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
RobN[_2_] RobN[_2_] is offline
external usenet poster
 
Posts: 230
Default Scramble a number

Hi Mike,

Thanks for that. Works perfectly for a single scramble.
I found some code on the internet that will list every possible permutation
, so I'm happy.

Rob


"Mike H" wrote in message
...
Hi,

Maybe a little simpler. ALT+F11 to open VB editor. Right click
'ThisWorkbook' and insert module and paste the code below in.

call with
=Mix(A1)

or

=Mix(123456) or =Mix(abcde)

Function Mix(Utext As Variant) As String
Dim i As Long
Dim NewPos As Long
Dim Temp As String
For i = 1 To Len(Utext)
Temp = Mid$(Utext, i, 1)
NewPos = Int(Len(Utext) * Rnd + 1)
Mid$(Utext, i, 1) = Mid$(Utext, NewPos, 1)
Mid$(Utext, NewPos, 1) = Temp
Next
Mix = Utext
End Function

Mike

"RobN" wrote:

Hi Jim,

I'm using Vs2007

Can't get this to work even with the modification. Always goes to:
SCRAMBLE = "No data"
Exit Function

I'm not too cluey wuth this sort of stuff, but the code you sent seems to
be
for text, not numbers, or doesn't that matter. (Or, don't I know what I'm
talking about? - the more likely option!)

Furthermore, in what cell do I need to put the number?

Rob


"Jim Cone" wrote in message
...
MORE INFO...
The function, as written calls the ExtractString function which I
forgot
to post.
The missing function enables SCRAMBLE to used in xl97.
The function is not needed(for later xl versions), if you just replace
the
following four lines of code...
'---
If Len(UserText) 0 Then
SpaceCount = COUNTIN(UserText, " ")
For i = 1 To SpaceCount + 1 'number of words in text
strWord = ExtractString(UserText, i, " ")

With...

If Len(UserText) 0 Then
SpaceCount = COUNTIN(UserText, " ")
For i = 0 To SpaceCount
strWord = VBA.Split(UserText, " ")(i)
--
Jim Cone
Portland, Oregon USA