Q:

How to use substitute function to decrypt and encrypt messages

I want to encrypt and decrypt messages by changing the character A to N, and B to O ..like you see in my code. I need some help to to that, thanks!!
Sub MacroCryptage()
Dim ws1 As Worksheet
Set ws1 = Worksheets("Feuil1")
Dim rng As Range, cell As Range
Set rng = ws1.Range("G" & 6)
Set cell = ws1.Range("G" & 5)

    rng = WorksheetFunction.Substitute(cell, "A", "N")
    rng = WorksheetFunction.Substitute(cell, "B", "O")
    rng = WorksheetFunction.Substitute(cell, "C", "P")
    rng = WorksheetFunction.Substitute(cell, "D", "Q")
    rng = WorksheetFunction.Substitute(cell, "E", "R")
    rng = WorksheetFunction.Substitute(cell, "F", "S")
    rng = WorksheetFunction.Substitute(cell, "G", "T")
    rng = WorksheetFunction.Substitute(cell, "H", "U")
    rng = WorksheetFunction.Substitute(cell, "I", "V")
    rng = WorksheetFunction.Substitute(cell, "J", "W")
    rng = WorksheetFunction.Substitute(cell, "K", "X")
    rng = WorksheetFunction.Substitute(cell, "L", "Y")
    rng = WorksheetFunction.Substitute(cell, "M", "Z")
    rng = WorksheetFunction.Substitute(cell, "N", "A")
    rng = WorksheetFunction.Substitute(cell, "O", "B")
    rng = WorksheetFunction.Substitute(cell, "P", "C")
    rng = WorksheetFunction.Substitute(cell, "Q", "D")
    rng = WorksheetFunction.Substitute(cell, "R", "E")
    rng = WorksheetFunction.Substitute(cell, "S", "F")
    rng = WorksheetFunction.Substitute(cell, "T", "G")
    rng = WorksheetFunction.Substitute(cell, "U", "H")
    rng = WorksheetFunction.Substitute(cell, "V", "I")
    rng = WorksheetFunction.Substitute(cell, "W", "J")
    rng = WorksheetFunction.Substitute(cell, "X", "K")
    rng = WorksheetFunction.Substitute(cell, "Y", "L")
    rng = WorksheetFunction.Substitute(cell, "Z", "M")

End Sub

A:

Your immediate problem is that your solution only applies to two specified cells. You should write it as a function that accepts the original text and returns the coded string
What you are looking at is ROT13. The simplest way to implement this is to use the ASCII values of the characters. In VBA you can use the ASC() function to return the ascii value of a char, then add 13 and then use the CHR() function to turn that value back into a character. This version only works on upper case text - characters 65 to 90. Lower case run 97 to 122 so you could add a test for that if you wanted 
Public Function Cypher(origtext as string) as string
dim s as string
dim answer as string
dim x as integer
dim myvar as integer
for x = 1 to len(origtext)
     s = mid(origtext,x,1)
     myvar = asc(s)+13
     if myvar > 90 then myvar = 65 + (myvar-90)
     s = chr(myvar)
     answer = answer & s
next x
Cypher = answer
End Function

To use this, in the spreadsheet enter =Cypher(cell ref) where cell ref contains teh text you want to cypher

