View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Encryption to change contents of a cell

You can use ROT13 encoding. It rotates the character code by 13 positions,
so the same algorithm can be used for encoding and decoding.

Sub encode()

Dim S As String
Dim s1 As String
Dim s2 As String

S = InputBox("enter String")
s1 = Rot13$(S)
' now decode
s2 = Rot13$(s1)
MsgBox _
"original: " & S & vbNewLine & _
"encoded: " & s1 & vbNewLine & _
"decoded: " & s2
End Sub

Function Rot13$(S As String)
Dim I, J As Integer
Dim T As String

For I = 1 To Len(S)
J = Asc(Mid$(S, I, 1))
If J = 65 And J <= 90 Then
J = ((J - 52) Mod 26) + 65
ElseIf J = 97 And J <= 122 Then
J = ((J - 84) Mod 26) + 97
End If
T = T + Chr$(J)
Next I
Rot13$ = T
End Function


New to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Tutorials:
http://www.mvps.org/dmcritchie/excel....htm#tutorials

the vba tutorials are after the excel tutorials.

--
Regards,
Tom Ogilvy


jase wrote in message
...


Hi all

I have a problem, in that i have a spreadsheet with a
column with a unique codes (next to the codes in the same
row are products), i now want to send this spreadsheet (or
part of it) to a customer but i DO NOT want them to see
the unique code (as it identifies who our supplier is), so
i want to make a temporary code, but as the customer will
mess around with the spreadsheet i don't just want to make
a code up, so i want to XOR (or use a cipher of somekind)
to change the code. this new code must be unique, and must
be able to change back to the original code.

I guess this includes macro's, but i ain't got a clue how
to use them!

Thanks in advance