I am trying to write a VBA macro that takes a single letter of the alphabet from the active cell and replaces it with a letter five positions ahead (i.e. "a" becomes "f", "x" becomes "c"). This is to decode a file of encrypted text where all letters have been shifted back five positions.
So far I have tried using the ASCII value of the letter and converting from that integer back to a character, but this seems not to be working (run time error 13) and I can't help but wonder if there is a more efficient way. Here's what I have so far:
Sub DECODER()
Worksheets("Sheet1").Activate
Dim What As String
What = ActiveCell.Value
Dim dCode As String
If What = "" Then
dCode = What
Else
dCode = Chr(Asc((What) + 5))
End If
ActiveCell.Value = dCode
End Sub