Sub ROT13Selection()
Dim c As Range
For Each c In Selection
c.Value = ROT13(c.Value)
Next c
End Sub
Sub Test()
Dim s As String
s = ROT13([A1])
MsgBox "Original String: " & [A1] & vbCrLf & _
"ROT13 String: " & ROT13([A1]) & vbCrLf & _
"ROT13(ROT13)) String: " & ROT13(ROT13([A1])), _
vbInformation, "ROT13"
End Sub
'ftp://ftp.pbhq.de/pbalgo/rot13-nl.bas
'
' ROT-13 encoder/decoder
' Created 26-02-1997
' By Marc van den Dikkenberg (pb@excelsior.xs4all.nl)
'
'Similar to, http://pitel-lnx.ibk.fnt.hvu.nl/~excel/pb.html
Function ROT13(Test$) As String
Dim tt As Long, x As Integer, y As Integer
For tt = 1 To Len(Test$)
y% = 0
x% = Asc(Mid$(Test$, tt, 1))
If (x% > 64 And x% < 91) Or (x% > 96 And x% < 123) Then
y% = 13
x% = x% - y%
If x% < 97 And x% > 83 Then x% = x% + 26 Else If x% < 65 Then x% = x% + 26
End If
Mid$(Test$, tt, 1) = Chr$(x%)
Next tt
ROT13 = Test$
End Function